Compile-Fixes in BetterEnd

This commit is contained in:
Frank 2022-05-17 18:09:43 +02:00
parent 6d6a1175b5
commit e3953167ba
174 changed files with 612 additions and 450 deletions

View file

@ -4,6 +4,7 @@ import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
@ -22,6 +23,9 @@ import ru.betterend.registry.EndParticles;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import net.minecraft.util.RandomSource;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class AncientEmeraldIceBlock extends BaseBlock {
public AncientEmeraldIceBlock() {
@ -30,7 +34,7 @@ public class AncientEmeraldIceBlock extends BaseBlock {
@Override
@SuppressWarnings("deprecation")
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
Direction dir = BlocksHelper.randomDirection(random);
if (random.nextBoolean()) {
@ -56,7 +60,7 @@ public class AncientEmeraldIceBlock extends BaseBlock {
}
}
private void makeParticles(ServerLevel world, BlockPos pos, Random random) {
private void makeParticles(ServerLevel world, BlockPos pos, RandomSource random) {
world.sendParticles(
EndParticles.SNOWFLAKE,
pos.getX() + 0.5,

View file

@ -109,10 +109,10 @@ public class AuroraCrystalBlock extends AbstractGlassBlock implements RenderLaye
if (min == max) {
return Lists.newArrayList(new ItemStack(EndItems.CRYSTAL_SHARDS, max));
}
count = MHelper.randRange(min, max, MHelper.RANDOM);
count = MHelper.randRange(min, max, MHelper.RANDOM_SOURCE);
}
else {
count = MHelper.randRange(MIN_DROP, MAX_DROP, MHelper.RANDOM);
count = MHelper.randRange(MIN_DROP, MAX_DROP, MHelper.RANDOM_SOURCE);
}
return Lists.newArrayList(new ItemStack(EndItems.CRYSTAL_SHARDS, count));
}

View file

@ -13,10 +13,14 @@ import ru.betterend.blocks.basis.FurBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class BlueVineSeedBlock extends EndPlantWithAgeBlock {
public BlueVineSeedBlock(){
super(p -> p.offsetType(BlockBehaviour.OffsetType.NONE));
}
@Override
public void growAdult(WorldGenLevel world, Random random, BlockPos pos) {
public void growAdult(WorldGenLevel world, RandomSource random, BlockPos pos) {
int height = MHelper.randRange(2, 5, random);
int h = BlocksHelper.upRay(world, pos, height + 2);
if (h < height + 1) {
@ -74,9 +78,4 @@ public class BlueVineSeedBlock extends EndPlantWithAgeBlock {
protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.END_MOSS) || state.is(EndBlocks.END_MYCELIUM);
}
@Override
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;
}
}

View file

@ -16,12 +16,13 @@ import ru.betterend.registry.EndBlocks;
import java.util.List;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class BoluxMushroomBlock extends EndPlantBlock {
private static final VoxelShape SHAPE = Block.box(1, 0, 1, 15, 9, 15);
public BoluxMushroomBlock() {
super(10);
super(10, p->p.offsetType(BlockBehaviour.OffsetType.NONE));
}
@Override
@ -34,10 +35,6 @@ public class BoluxMushroomBlock extends EndPlantBlock {
return SHAPE;
}
@Override
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;
}
@Override
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
@ -45,7 +42,7 @@ public class BoluxMushroomBlock extends EndPlantBlock {
}
@Override
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
public boolean isBonemealSuccess(Level world, RandomSource random, BlockPos pos, BlockState state) {
return false;
}

View file

@ -23,6 +23,7 @@ import ru.bclib.util.BlocksHelper;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class BrimstoneBlock extends BaseBlock {
public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVE;
@ -65,7 +66,7 @@ public class BrimstoneBlock extends BaseBlock {
@Override
@SuppressWarnings("deprecation")
public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
boolean deactivate = true;
for (Direction dir : BlocksHelper.DIRECTIONS) {
if (world.getFluidState(pos.relative(dir)).getType().equals(Fluids.WATER)) {

View file

@ -18,6 +18,7 @@ import ru.bclib.interfaces.tools.AddMineableShears;
import ru.betterend.blocks.basis.EndUnderwaterPlantBlock;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class BubbleCoralBlock extends EndUnderwaterPlantBlock implements AddMineableShears {
@ -26,16 +27,12 @@ public class BubbleCoralBlock extends EndUnderwaterPlantBlock implements AddMine
public BubbleCoralBlock() {
super(FabricBlockSettings.of(Material.WATER_PLANT)
.sound(SoundType.CORAL_BLOCK)
.noCollission());
}
@Override
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;
.noCollission()
.offsetType(BlockBehaviour.OffsetType.NONE));
}
@Environment(EnvType.CLIENT)
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
public void animateTick(BlockState state, Level world, BlockPos pos, RandomSource random) {
double x = pos.getX() + random.nextDouble();
double y = pos.getY() + random.nextDouble() * 0.5F + 0.5F;
double z = pos.getZ() + random.nextDouble();
@ -53,7 +50,7 @@ public class BubbleCoralBlock extends EndUnderwaterPlantBlock implements AddMine
}
@Override
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
public boolean isBonemealSuccess(Level world, RandomSource random, BlockPos pos, BlockState state) {
return false;
}
}

View file

@ -13,6 +13,7 @@ import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class BulbVineSeedBlock extends EndPlantWithAgeBlock {
@ -23,7 +24,7 @@ public class BulbVineSeedBlock extends EndPlantWithAgeBlock {
}
@Override
public void growAdult(WorldGenLevel world, Random random, BlockPos pos) {
public void growAdult(WorldGenLevel world, RandomSource random, BlockPos pos) {
int h = BlocksHelper.downRay(world, pos, random.nextInt(24)) - 1;
if (h > 2) {
BlocksHelper.setWithoutUpdate(

View file

@ -17,8 +17,12 @@ import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class CavePumpkinVineBlock extends EndPlantWithAgeBlock {
public CavePumpkinVineBlock(){
super(p->p.offsetType(BlockBehaviour.OffsetType.NONE));
}
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 16, 12);
@Override
@ -28,7 +32,7 @@ public class CavePumpkinVineBlock extends EndPlantWithAgeBlock {
}
@Override
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) {
public void performBonemeal(ServerLevel world, RandomSource random, BlockPos pos, BlockState state) {
int age = state.getValue(AGE);
BlockState down = world.getBlockState(pos.below());
if (down.getMaterial()
@ -49,7 +53,7 @@ public class CavePumpkinVineBlock extends EndPlantWithAgeBlock {
}
@Override
public void growAdult(WorldGenLevel world, Random random, BlockPos pos) {
public void growAdult(WorldGenLevel world, RandomSource random, BlockPos pos) {
}
@Override
@ -68,9 +72,4 @@ public class CavePumpkinVineBlock extends EndPlantWithAgeBlock {
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE;
}
@Override
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;
}
}

View file

@ -28,6 +28,7 @@ import ru.bclib.interfaces.RenderLayerProvider;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class EmeraldIceBlock extends HalfTransparentBlock implements RenderLayerProvider, BlockModelProvider {
public EmeraldIceBlock() {
@ -58,7 +59,7 @@ public class EmeraldIceBlock extends HalfTransparentBlock implements RenderLayer
@Override
@SuppressWarnings("deprecation")
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
if (world.getBrightness(LightLayer.BLOCK, pos) > 11 - state.getLightBlock(world, pos)) {
this.melt(state, world, pos);
}

View file

@ -35,6 +35,7 @@ import ru.betterend.registry.EndItems;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class EndLilyBlock extends EndUnderwaterPlantBlock implements AddMineableShears {
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
@ -95,8 +96,8 @@ public class EndLilyBlock extends EndUnderwaterPlantBlock implements AddMineable
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
if (state.getValue(SHAPE) == TripleShape.TOP) {
return Lists.newArrayList(
new ItemStack(EndItems.END_LILY_LEAF, MHelper.randRange(1, 2, MHelper.RANDOM)),
new ItemStack(EndBlocks.END_LILY_SEED, MHelper.randRange(1, 2, MHelper.RANDOM))
new ItemStack(EndItems.END_LILY_LEAF, MHelper.randRange(1, 2, MHelper.RANDOM_SOURCE)),
new ItemStack(EndBlocks.END_LILY_SEED, MHelper.randRange(1, 2, MHelper.RANDOM_SOURCE))
);
}
return Collections.emptyList();
@ -114,7 +115,7 @@ public class EndLilyBlock extends EndUnderwaterPlantBlock implements AddMineable
}
@Override
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
public boolean isBonemealSuccess(Level world, RandomSource random, BlockPos pos, BlockState state) {
return false;
}
}

View file

@ -11,10 +11,11 @@ import ru.bclib.util.BlocksHelper;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class EndLilySeedBlock extends UnderwaterPlantWithAgeBlock {
@Override
public void grow(WorldGenLevel world, Random random, BlockPos pos) {
public void grow(WorldGenLevel world, RandomSource random, BlockPos pos) {
if (canGrow(world, pos)) {
BlocksHelper.setWithoutUpdate(
world,

View file

@ -25,7 +25,7 @@ public class EndLotusFlowerBlock extends EndPlantBlock {
private static final VoxelShape SHAPE_COLLISION = Block.box(0, 0, 0, 16, 2, 16);
public EndLotusFlowerBlock() {
super(FabricBlockSettings.of(Material.PLANT).luminance(15).noOcclusion());
super(FabricBlockSettings.of(Material.PLANT).luminance(15).noOcclusion().offsetType(BlockBehaviour.OffsetType.NONE));
}
@Override
@ -33,11 +33,6 @@ public class EndLotusFlowerBlock extends EndPlantBlock {
return state.is(EndBlocks.END_LOTUS_STEM);
}
@Override
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
return SHAPE_OUTLINE;
@ -51,7 +46,7 @@ public class EndLotusFlowerBlock extends EndPlantBlock {
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
int count = MHelper.randRange(1, 2, MHelper.RANDOM);
int count = MHelper.randRange(1, 2, MHelper.RANDOM_SOURCE);
return Lists.newArrayList(new ItemStack(EndBlocks.END_LOTUS_SEED, count));
}

View file

@ -13,10 +13,11 @@ import ru.bclib.util.BlocksHelper;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class EndLotusSeedBlock extends UnderwaterPlantWithAgeBlock {
@Override
public void grow(WorldGenLevel world, Random random, BlockPos pos) {
public void grow(WorldGenLevel world, RandomSource random, BlockPos pos) {
if (canGrow(world, pos)) {
BlockState startLeaf = EndBlocks.END_LOTUS_STEM.defaultBlockState().setValue(EndLotusStemBlock.LEAF, true);
BlockState roots = EndBlocks.END_LOTUS_STEM.defaultBlockState()

View file

@ -39,6 +39,7 @@ import ru.betterend.rituals.EternalRitual;
import java.util.Objects;
import java.util.Optional;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class EndPortalBlock extends NetherPortalBlock implements RenderLayerProvider, CustomColorProvider {
public static final IntegerProperty PORTAL = EndBlockProperties.PORTAL;
@ -57,7 +58,7 @@ public class EndPortalBlock extends NetherPortalBlock implements RenderLayerProv
@Override
@Environment(EnvType.CLIENT)
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
public void animateTick(BlockState state, Level world, BlockPos pos, RandomSource random) {
if (random.nextInt(100) == 0) {
world.playLocalSound(
pos.getX() + 0.5D,
@ -86,7 +87,7 @@ public class EndPortalBlock extends NetherPortalBlock implements RenderLayerProv
}
@Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
}
@Override

View file

@ -42,6 +42,7 @@ import ru.betterend.registry.EndBlockEntities;
import java.util.List;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class EndStoneSmelter extends BaseBlockWithEntity {
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
@ -138,7 +139,7 @@ public class EndStoneSmelter extends BaseBlockWithEntity {
}
@Environment(EnvType.CLIENT)
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
public void animateTick(BlockState state, Level world, BlockPos pos, RandomSource random) {
if (state.getValue(LIT)) {
double x = pos.getX() + 0.5D;
double y = pos.getY();

View file

@ -5,11 +5,6 @@ import ru.bclib.blocks.BaseVineBlock;
public class FilaluxBlock extends BaseVineBlock {
public FilaluxBlock() {
super(15, true);
}
@Override
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;
super(15, true, p->p.offsetType(BlockBehaviour.OffsetType.NONE));
}
}

View file

@ -7,7 +7,8 @@ import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.WaterLilyBlockItem;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.PlaceOnWaterBlockItem;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
@ -29,7 +30,8 @@ public class FlamaeaBlock extends EndPlantBlock implements CustomItemProvider, A
public FlamaeaBlock() {
super(FabricBlockSettings.of(Material.PLANT)
.sound(SoundType.WET_GRASS));
.sound(SoundType.WET_GRASS)
.offsetType( BlockBehaviour.OffsetType.NONE));
}
@Override
@ -42,11 +44,6 @@ public class FlamaeaBlock extends EndPlantBlock implements CustomItemProvider, A
return SHAPE;
}
@Override
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;
}
@Override
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return Lists.newArrayList(new ItemStack(this));
@ -59,6 +56,6 @@ public class FlamaeaBlock extends EndPlantBlock implements CustomItemProvider, A
@Override
public BlockItem getCustomItem(ResourceLocation resourceLocation, FabricItemSettings fabricItemSettings) {
return new WaterLilyBlockItem(this, fabricItemSettings);
return new PlaceOnWaterBlockItem(this, fabricItemSettings);
}
}

View file

@ -18,7 +18,7 @@ public class FlammalixBlock extends EndPlantBlock {
private static final VoxelShape SHAPE = Block.box(2, 0, 2, 14, 14, 14);
public FlammalixBlock() {
super(false, 12);
super(false, 12, p->p.offsetType(OffsetType.NONE));
}
@Override
@ -34,11 +34,6 @@ public class FlammalixBlock extends EndPlantBlock {
return SHAPE;
}
@Override
public OffsetType getOffsetType() {
return OffsetType.NONE;
}
@Override
@Environment(EnvType.CLIENT)
public BlockModel getItemModel(ResourceLocation resourceLocation) {

View file

@ -302,7 +302,7 @@ public class FlowerPotBlock extends BaseBlockNotFull implements RenderLayerProvi
"models/block/" + modelPath.getPath() + "_potted.json"
);
if (Minecraft.getInstance().getResourceManager().hasResource(objSource)) {
if (Minecraft.getInstance().getResourceManager().getResource(objSource).isPresent()) {
objSource = new ResourceLocation(modelPath.getNamespace(), "block/" + modelPath.getPath() + "_potted");
model.part(objSource)
.setTransformation(offset)

View file

@ -19,6 +19,7 @@ import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class GlowingPillarSeedBlock extends EndPlantWithAgeBlock implements AddMineableShears {
@ -27,11 +28,12 @@ public class GlowingPillarSeedBlock extends EndPlantWithAgeBlock implements AddM
.sound(SoundType.GRASS)
.lightLevel(state -> state.getValue(AGE) * 3 + 3)
.randomTicks()
.noCollission());
.noCollission()
.offsetType(OffsetType.NONE));
}
@Override
public void growAdult(WorldGenLevel world, Random random, BlockPos pos) {
public void growAdult(WorldGenLevel world, RandomSource random, BlockPos pos) {
int height = MHelper.randRange(1, 2, random);
int h = BlocksHelper.upRay(world, pos, height + 2);
if (h < height) {
@ -78,9 +80,4 @@ public class GlowingPillarSeedBlock extends EndPlantWithAgeBlock implements AddM
protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.AMBER_MOSS);
}
@Override
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;
}
}

View file

@ -27,6 +27,7 @@ import ru.betterend.registry.EndItems;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class HydraluxBlock extends UnderwaterPlantBlock implements AddMineableShears {
@ -70,7 +71,7 @@ public class HydraluxBlock extends UnderwaterPlantBlock implements AddMineableS
}
@Override
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
public boolean isBonemealSuccess(Level world, RandomSource random, BlockPos pos, BlockState state) {
return false;
}
@ -84,12 +85,12 @@ public class HydraluxBlock extends UnderwaterPlantBlock implements AddMineableS
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
HydraluxShape shape = state.getValue(SHAPE);
if (shape == HydraluxShape.FLOWER_BIG_BOTTOM || shape == HydraluxShape.FLOWER_SMALL_BOTTOM) {
return Lists.newArrayList(new ItemStack(EndItems.HYDRALUX_PETAL, MHelper.randRange(1, 4, MHelper.RANDOM)));
return Lists.newArrayList(new ItemStack(EndItems.HYDRALUX_PETAL, MHelper.randRange(1, 4, MHelper.RANDOM_SOURCE)));
}
else if (shape == HydraluxShape.ROOTS) {
return Lists.newArrayList(new ItemStack(
EndBlocks.HYDRALUX_SAPLING,
MHelper.randRange(1, 2, MHelper.RANDOM)
MHelper.randRange(1, 2, MHelper.RANDOM_SOURCE)
));
}
return Collections.emptyList();

View file

@ -12,11 +12,12 @@ import ru.betterend.blocks.EndBlockProperties.HydraluxShape;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class HydraluxSaplingBlock extends UnderwaterPlantWithAgeBlock {
@Override
public void grow(WorldGenLevel world, Random random, BlockPos pos) {
public void grow(WorldGenLevel world, RandomSource random, BlockPos pos) {
int h = MHelper.randRange(4, 8, random);
MutableBlockPos mut = new MutableBlockPos().set(pos);

View file

@ -42,6 +42,7 @@ import ru.betterend.blocks.entities.BlockEntityHydrothermalVent;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
import net.minecraft.util.RandomSource;
@SuppressWarnings("deprecation")
public class HydrothermalVentBlock extends BaseBlockNotFull implements EntityBlock, LiquidBlockContainer, SimpleWaterloggedBlock, AddMineablePickaxe {
@ -113,7 +114,7 @@ public class HydrothermalVentBlock extends BaseBlockNotFull implements EntityBlo
}
@Override
public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
BlockPos up = pos.above();
if (world.getBlockState(up).is(Blocks.WATER)) {
BlocksHelper.setWithoutUpdate(world, up, EndBlocks.VENT_BUBBLE_COLUMN);
@ -130,7 +131,7 @@ public class HydrothermalVentBlock extends BaseBlockNotFull implements EntityBlo
}
@Environment(EnvType.CLIENT)
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
public void animateTick(BlockState state, Level world, BlockPos pos, RandomSource random) {
super.animateTick(state, world, pos, random);
if (!state.getValue(ACTIVATED) && random.nextBoolean()) {
double x = pos.getX() + random.nextDouble();

View file

@ -14,10 +14,14 @@ import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class LanceleafSeedBlock extends EndPlantWithAgeBlock {
public LanceleafSeedBlock() {
super(p->p.offsetType(OffsetType.NONE));
}
@Override
public void growAdult(WorldGenLevel world, Random random, BlockPos pos) {
public void growAdult(WorldGenLevel world, RandomSource random, BlockPos pos) {
int height = MHelper.randRange(4, 6, random);
int h = BlocksHelper.upRay(world, pos, height + 2);
if (h < height + 1) {
@ -55,9 +59,4 @@ public class LanceleafSeedBlock extends EndPlantWithAgeBlock {
protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.AMBER_MOSS);
}
@Override
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;
}
}

View file

@ -21,6 +21,7 @@ import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class LargeAmaranitaBlock extends EndPlantBlock implements AddMineableShears {
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
@ -31,7 +32,8 @@ public class LargeAmaranitaBlock extends EndPlantBlock implements AddMineableShe
super(FabricBlockSettings.of(Material.PLANT)
.sound(SoundType.GRASS)
.lightLevel((state) -> (state.getValue(SHAPE) == TripleShape.TOP) ? 15 : 0));
.lightLevel((state) -> (state.getValue(SHAPE) == TripleShape.TOP) ? 15 : 0)
.offsetType(OffsetType.NONE));
}
@Override
@ -63,18 +65,13 @@ public class LargeAmaranitaBlock extends EndPlantBlock implements AddMineableShe
}
}
@Override
public OffsetType getOffsetType() {
return OffsetType.NONE;
}
@Override
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
return false;
}
@Override
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
public boolean isBonemealSuccess(Level world, RandomSource random, BlockPos pos, BlockState state) {
return false;
}
}

View file

@ -88,7 +88,7 @@ public class LumecornBlock extends BaseBlockNotFull implements RenderLayerProvid
if (shape == LumecornShape.BOTTOM_BIG || shape == LumecornShape.BOTTOM_SMALL || shape == LumecornShape.MIDDLE) {
return Collections.singletonList(new ItemStack(
EndBlocks.LUMECORN_SEED,
MHelper.randRange(1, 2, MHelper.RANDOM)
MHelper.randRange(1, 2, MHelper.RANDOM_SOURCE)
));
}
return MHelper.RANDOM.nextBoolean() ? Collections.singletonList(new ItemStack(EndItems.LUMECORN_ROD)) : Collections

View file

@ -13,11 +13,16 @@ import ru.betterend.registry.EndFeatures;
import java.util.Optional;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class LumecornSeedBlock extends EndPlantWithAgeBlock {
public LumecornSeedBlock(){
super(p->p.offsetType(OffsetType.NONE));
}
@Override
public void growAdult(WorldGenLevel world, Random random, BlockPos pos) {
public void growAdult(WorldGenLevel world, RandomSource random, BlockPos pos) {
((Feature<NoneFeatureConfiguration>) (EndFeatures.LUMECORN.getFeature())).place(new FeaturePlaceContext<>(
Optional.empty(),
world,
@ -31,9 +36,4 @@ public class LumecornSeedBlock extends EndPlantWithAgeBlock {
protected boolean isTerrain(BlockState state) {
return state.is(EndBlocks.END_MOSS);
}
@Override
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;
}
}

View file

@ -27,6 +27,7 @@ import ru.bclib.util.BlocksHelper;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
import net.minecraft.util.RandomSource;
@SuppressWarnings("deprecation")
public class MengerSpongeWetBlock extends BaseBlockNotFull implements RenderLayerProvider {
@ -52,7 +53,7 @@ public class MengerSpongeWetBlock extends BaseBlockNotFull implements RenderLaye
@Override
@Environment(EnvType.CLIENT)
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
public void animateTick(BlockState state, Level world, BlockPos pos, RandomSource random) {
Direction direction = Direction.getRandom(random);
if (direction != Direction.UP) {
BlockPos blockPos = pos.relative(direction);

View file

@ -20,6 +20,7 @@ import ru.betterend.registry.EndBlocks;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import net.minecraft.util.RandomSource;
@SuppressWarnings("deprecation")
public class MossyDragonBoneBlock extends BaseRotatedPillarBlock {
@ -37,7 +38,7 @@ public class MossyDragonBoneBlock extends BaseRotatedPillarBlock {
}
@Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
if (random.nextInt(16) == 0 && !canSurvive(state, world, pos)) {
world.setBlockAndUpdate(pos, Blocks.BONE_BLOCK.defaultBlockState().setValue(AXIS, state.getValue(AXIS)));
}

View file

@ -19,6 +19,7 @@ import ru.bclib.blocks.BaseBlock;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class MossyObsidian extends BaseBlock {
public MossyObsidian() {
@ -36,7 +37,7 @@ public class MossyObsidian extends BaseBlock {
@Override
@SuppressWarnings("deprecation")
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
if (random.nextInt(16) == 0 && !canSurvive(state, world, pos)) {
world.setBlockAndUpdate(pos, Blocks.OBSIDIAN.defaultBlockState());
}

View file

@ -16,11 +16,12 @@ import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class MurkweedBlock extends EndPlantBlock {
@Override
@Environment(EnvType.CLIENT)
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
public void animateTick(BlockState state, Level world, BlockPos pos, RandomSource random) {
double x = pos.getX() + random.nextDouble();
double y = pos.getY() + random.nextDouble() * 0.5 + 0.5;
double z = pos.getZ() + random.nextDouble();

View file

@ -41,7 +41,7 @@ public class NeedlegrassBlock extends EndPlantBlock {
return Lists.newArrayList(new ItemStack(this));
}
else {
return Lists.newArrayList(new ItemStack(Items.STICK, MHelper.randRange(0, 2, MHelper.RANDOM)));
return Lists.newArrayList(new ItemStack(Items.STICK, MHelper.randRange(0, 2, MHelper.RANDOM_SOURCE)));
}
}

View file

@ -49,6 +49,7 @@ import ru.betterend.registry.EndBlocks;
import java.util.EnumMap;
import java.util.List;
import java.util.Random;
import net.minecraft.util.RandomSource;
@SuppressWarnings("deprecation")
public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWaterloggedBlock, RenderLayerProvider, PottablePlant {
@ -134,7 +135,7 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
}
@Override
public void tick(BlockState blockState, ServerLevel serverLevel, BlockPos blockPos, Random random) {
public void tick(BlockState blockState, ServerLevel serverLevel, BlockPos blockPos, RandomSource random) {
if (!blockState.canSurvive(serverLevel, blockPos)) {
serverLevel.destroyBlock(blockPos, true, null, 1);
}
@ -174,7 +175,7 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
}
@Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
if (!this.canSurvive(state, world, pos) || random.nextInt(8) > 0) {
return;
}
@ -214,11 +215,11 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
mutateStem(placement, world, pos, MAX_LENGTH);
}
public void growPlant(WorldGenLevel world, BlockPos pos, Random random) {
public void growPlant(WorldGenLevel world, BlockPos pos, RandomSource random) {
growPlant(world, pos, random, MHelper.randRange(MAX_LENGTH >> 1, MAX_LENGTH, random));
}
public void growPlant(WorldGenLevel world, BlockPos pos, Random random, int iterations) {
public void growPlant(WorldGenLevel world, BlockPos pos, RandomSource random, int iterations) {
BlockState state = defaultBlockState();
BlockState downState = world.getBlockState(pos.below());
if (downState.is(Blocks.END_STONE) || downState.is(EndBlocks.ENDSTONE_DUST)) {
@ -244,7 +245,7 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
}
}
private boolean growIteration(WorldGenLevel world, MutableBlockPos pos, Random random, List<MutableBlockPos> ends, int length) {
private boolean growIteration(WorldGenLevel world, MutableBlockPos pos, RandomSource random, List<MutableBlockPos> ends, int length) {
BlockState state = world.getBlockState(pos);
if (!state.is(this)) {
return false;
@ -284,7 +285,7 @@ public class NeonCactusPlantBlock extends BaseBlockNotFull implements SimpleWate
return true;
}
private Direction getSideDirection(WorldGenLevel world, BlockPos pos, BlockState iterState, Direction dir, Random random) {
private Direction getSideDirection(WorldGenLevel world, BlockPos pos, BlockState iterState, Direction dir, RandomSource random) {
MutableBlockPos iterPos = pos.mutable();
Direction startDir = dir;
Direction lastDir = null;

View file

@ -18,6 +18,7 @@ import ru.bclib.interfaces.tools.AddMineableShears;
import ru.betterend.blocks.basis.EndUnderwaterPlantBlock;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class PondAnemoneBlock extends EndUnderwaterPlantBlock implements AddMineableShears {
private static final VoxelShape SHAPE = Block.box(2, 0, 2, 14, 14, 14);
@ -27,16 +28,12 @@ public class PondAnemoneBlock extends EndUnderwaterPlantBlock implements AddMine
.luminance(13)
.sound(SoundType.CORAL_BLOCK)
.noCollission());
}
@Override
public BlockBehaviour.OffsetType getOffsetType() {
return BlockBehaviour.OffsetType.NONE;
.noCollission()
.offsetType(OffsetType.NONE));
}
@Environment(EnvType.CLIENT)
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
public void animateTick(BlockState state, Level world, BlockPos pos, RandomSource random) {
double x = pos.getX() + random.nextDouble();
double y = pos.getY() + random.nextDouble() * 0.5F + 0.5F;
double z = pos.getZ() + random.nextDouble();
@ -54,7 +51,7 @@ public class PondAnemoneBlock extends EndUnderwaterPlantBlock implements AddMine
}
@Override
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
public boolean isBonemealSuccess(Level world, RandomSource random, BlockPos pos, BlockState state) {
return false;
}
}

View file

@ -6,7 +6,8 @@ import net.minecraft.client.color.block.BlockColor;
import net.minecraft.client.color.item.ItemColor;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvents;
@ -167,8 +168,8 @@ public class RespawnObeliskBlock extends BaseBlock implements CustomColorProvide
if (!world.isClientSide && !(itemStack.getItem() instanceof BlockItem) && !player.isCreative()) {
ServerPlayer serverPlayerEntity = (ServerPlayer) player;
serverPlayerEntity.displayClientMessage(
new TranslatableComponent("message.betterend.fail_spawn"),
true
Component.translatable("message.betterend.fail_spawn"),
true
);
}
return InteractionResult.FAIL;
@ -176,7 +177,7 @@ public class RespawnObeliskBlock extends BaseBlock implements CustomColorProvide
else if (!world.isClientSide) {
ServerPlayer serverPlayerEntity = (ServerPlayer) player;
serverPlayerEntity.setRespawnPosition(world.dimension(), pos, 0.0F, false, false);
serverPlayerEntity.displayClientMessage(new TranslatableComponent("message.betterend.set_spawn"), true);
serverPlayerEntity.displayClientMessage(Component.translatable("message.betterend.set_spawn"), true);
double px = pos.getX() + 0.5;
double py = pos.getY() + 0.5;
double pz = pos.getZ() + 0.5;

View file

@ -16,6 +16,7 @@ import ru.betterend.registry.EndParticles;
import java.util.List;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class ShadowGrassBlock extends EndTerrainBlock implements TagProvider {
public ShadowGrassBlock() {
@ -23,7 +24,7 @@ public class ShadowGrassBlock extends EndTerrainBlock implements TagProvider {
}
@Environment(EnvType.CLIENT)
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
public void animateTick(BlockState state, Level world, BlockPos pos, RandomSource random) {
super.animateTick(state, world, pos, random);
if (random.nextInt(32) == 0) {
world.addParticle(

View file

@ -35,6 +35,7 @@ import ru.betterend.registry.EndEntities;
import ru.betterend.registry.EndItems;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class SilkMothHiveBlock extends BaseBlock {
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
@ -75,7 +76,7 @@ public class SilkMothHiveBlock extends BaseBlock {
@Override
@SuppressWarnings("deprecation")
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
Direction dir = state.getValue(FACING);
BlockPos spawn = pos.relative(dir);
if (!world.getBlockState(spawn).isAir()) {

View file

@ -47,6 +47,7 @@ import ru.betterend.registry.EndItems;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class SilkMothNestBlock extends BaseBlock implements RenderLayerProvider {
public static final BooleanProperty ACTIVE = EndBlockProperties.ACTIVE;
@ -133,7 +134,7 @@ public class SilkMothNestBlock extends BaseBlock implements RenderLayerProvider
@Override
@SuppressWarnings("deprecation")
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
if (!state.getValue(ACTIVE)) {
return;
}

View file

@ -20,6 +20,7 @@ import ru.betterend.registry.EndFeatures;
import java.util.Optional;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class SmallAmaranitaBlock extends EndPlantBlock {
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 10, 12);
@ -30,7 +31,7 @@ public class SmallAmaranitaBlock extends EndPlantBlock {
}
@Override
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) {
public void performBonemeal(ServerLevel world, RandomSource random, BlockPos pos, BlockState state) {
BlockPos bigPos = growBig(world, pos);
if (bigPos != null) {
if (((Feature<NoneFeatureConfiguration>)EndFeatures.GIGANTIC_AMARANITA.getFeature())
@ -75,7 +76,7 @@ public class SmallAmaranitaBlock extends EndPlantBlock {
}
@Override
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
public boolean isBonemealSuccess(Level world, RandomSource random, BlockPos pos, BlockState state) {
return random.nextInt(8) == 0;
}
}

View file

@ -41,6 +41,7 @@ import java.util.EnumMap;
import java.util.List;
import java.util.Optional;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class SmallJellyshroomBlock extends BaseAttachedBlock implements RenderLayerProvider, BonemealableBlock, PottablePlant {
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
@ -97,12 +98,12 @@ public class SmallJellyshroomBlock extends BaseAttachedBlock implements RenderLa
}
@Override
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
public boolean isBonemealSuccess(Level world, RandomSource random, BlockPos pos, BlockState state) {
return random.nextInt(16) == 0;
}
@Override
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) {
public void performBonemeal(ServerLevel world, RandomSource random, BlockPos pos, BlockState state) {
BlocksHelper.setWithUpdate(world, pos, Blocks.AIR);
((Feature<NoneFeatureConfiguration>)EndFeatures.JELLYSHROOM.getFeature()).place(new FeaturePlaceContext<>(Optional.empty(), world, null, random, pos, null));
}

View file

@ -69,7 +69,7 @@ public class SulphurCrystalBlock extends BaseAttachedBlock implements AddMineabl
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
return state.getValue(AGE) < 2 ? Collections.emptyList() : Lists.newArrayList(new ItemStack(
EndItems.CRYSTALLINE_SULPHUR,
MHelper.randRange(1, 3, MHelper.RANDOM)
MHelper.randRange(1, 3, MHelper.RANDOM_SOURCE)
));
}

View file

@ -17,6 +17,7 @@ import ru.bclib.util.MHelper;
import ru.betterend.registry.EndParticles;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class TenaneaFlowersBlock extends BaseVineBlock implements CustomColorProvider {
public static final Vec3i[] COLORS;
@ -62,7 +63,7 @@ public class TenaneaFlowersBlock extends BaseVineBlock implements CustomColorPro
}
@Environment(EnvType.CLIENT)
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
public void animateTick(BlockState state, Level world, BlockPos pos, RandomSource random) {
super.animateTick(state, world, pos, random);
if (random.nextInt(32) == 0) {
double x = (double) pos.getX() + random.nextGaussian() + 0.5;

View file

@ -13,6 +13,7 @@ import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class TwistedUmbrellaMossBlock extends EndPlantBlock {
public TwistedUmbrellaMossBlock() {
@ -35,12 +36,12 @@ public class TwistedUmbrellaMossBlock extends EndPlantBlock {
}
@Override
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
public boolean isBonemealSuccess(Level world, RandomSource random, BlockPos pos, BlockState state) {
return world.isEmptyBlock(pos.above());
}
@Override
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) {
public void performBonemeal(ServerLevel world, RandomSource random, BlockPos pos, BlockState state) {
int rot = world.random.nextInt(4);
BlockState bs = EndBlocks.TWISTED_UMBRELLA_MOSS_TALL.defaultBlockState()
.setValue(BaseDoublePlantBlock.ROTATION, rot);

View file

@ -9,6 +9,7 @@ import ru.bclib.blocks.BaseDoublePlantBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class TwistedUmbrellaMossTallBlock extends BaseDoublePlantBlock {
public TwistedUmbrellaMossTallBlock() {
@ -16,7 +17,7 @@ public class TwistedUmbrellaMossTallBlock extends BaseDoublePlantBlock {
}
@Override
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) {
public void performBonemeal(ServerLevel world, RandomSource random, BlockPos pos, BlockState state) {
ItemEntity item = new ItemEntity(
world,
pos.getX() + 0.5,

View file

@ -13,6 +13,7 @@ import ru.betterend.blocks.basis.EndPlantBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class UmbrellaMossBlock extends EndPlantBlock {
public UmbrellaMossBlock() {
@ -35,12 +36,12 @@ public class UmbrellaMossBlock extends EndPlantBlock {
}
@Override
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
public boolean isBonemealSuccess(Level world, RandomSource random, BlockPos pos, BlockState state) {
return world.isEmptyBlock(pos.above());
}
@Override
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) {
public void performBonemeal(ServerLevel world, RandomSource random, BlockPos pos, BlockState state) {
int rot = world.random.nextInt(4);
BlockState bs = EndBlocks.UMBRELLA_MOSS_TALL.defaultBlockState().setValue(BaseDoublePlantBlock.ROTATION, rot);
BlocksHelper.setWithoutUpdate(world, pos, bs);

View file

@ -9,6 +9,7 @@ import ru.bclib.blocks.BaseDoublePlantBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class UmbrellaMossTallBlock extends BaseDoublePlantBlock {
public UmbrellaMossTallBlock() {
@ -16,7 +17,7 @@ public class UmbrellaMossTallBlock extends BaseDoublePlantBlock {
}
@Override
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) {
public void performBonemeal(ServerLevel world, RandomSource random, BlockPos pos, BlockState state) {
ItemEntity item = new ItemEntity(
world,
pos.getX() + 0.5,

View file

@ -14,6 +14,7 @@ import ru.bclib.util.BlocksHelper;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class UmbrellaTreeClusterEmptyBlock extends BaseBlock {
public static final BooleanProperty NATURAL = EndBlockProperties.NATURAL;
@ -34,7 +35,7 @@ public class UmbrellaTreeClusterEmptyBlock extends BaseBlock {
@Override
@SuppressWarnings("deprecation")
public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
if (state.getValue(NATURAL) && random.nextInt(16) == 0) {
BlocksHelper.setWithUpdate(
world,

View file

@ -35,6 +35,7 @@ import ru.betterend.registry.EndBlocks;
import java.util.Optional;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class VentBubbleColumnBlock extends Block implements BucketPickup, LiquidBlockContainer {
public VentBubbleColumnBlock() {
@ -83,7 +84,7 @@ public class VentBubbleColumnBlock extends Block implements BucketPickup, Liquid
}
@Environment(EnvType.CLIENT)
public void animateTick(BlockState state, Level world, BlockPos pos, Random random) {
public void animateTick(BlockState state, Level world, BlockPos pos, RandomSource random) {
if (random.nextInt(4) == 0) {
double px = pos.getX() + random.nextDouble();
double py = pos.getY() + random.nextDouble();

View file

@ -6,21 +6,32 @@ import ru.bclib.api.tag.CommonBlockTags;
import ru.bclib.blocks.BasePlantBlock;
import ru.betterend.interfaces.PottablePlant;
import java.util.function.Function;
public class EndPlantBlock extends BasePlantBlock implements PottablePlant {
public EndPlantBlock() {
this(false);
this(false, p->p);
}
public EndPlantBlock(int light) {
this(false, light);
this(light, p->p);
}
public EndPlantBlock(int light, Function<Properties, Properties> propMod) {
this(false, light, propMod);
}
public EndPlantBlock(boolean replaceable) {
super(replaceable);
}
public EndPlantBlock(boolean replaceable, Function<Properties, Properties> propMod) {
super(replaceable, propMod);
}
public EndPlantBlock(boolean replaceable, int light) {
super(replaceable, light);
public EndPlantBlock(boolean replaceable, int light){
this(replaceable, light, p->p);
}
public EndPlantBlock(boolean replaceable, int light, Function<Properties, Properties> propMod) {
super(replaceable, light, propMod);
}
public EndPlantBlock(Properties settings) {

View file

@ -4,11 +4,17 @@ import net.minecraft.world.level.block.state.BlockState;
import ru.bclib.api.tag.CommonBlockTags;
import ru.bclib.blocks.BasePlantWithAgeBlock;
import java.util.function.Function;
public abstract class EndPlantWithAgeBlock extends BasePlantWithAgeBlock {
public EndPlantWithAgeBlock() {
}
public EndPlantWithAgeBlock(Function<Properties, Properties> propMod) {
super(propMod);
}
public EndPlantWithAgeBlock(Properties settings) {
super(settings);
}

View file

@ -4,13 +4,15 @@ import net.minecraft.world.level.block.state.BlockState;
import ru.bclib.api.tag.CommonBlockTags;
import ru.bclib.blocks.UnderwaterPlantBlock;
import java.util.function.Function;
public class EndUnderwaterPlantBlock extends UnderwaterPlantBlock {
public EndUnderwaterPlantBlock() {
}
public EndUnderwaterPlantBlock(int light) {
super(light);
public EndUnderwaterPlantBlock(int light, Function<Properties, Properties> propMod) {
super(light, propMod);
}
public EndUnderwaterPlantBlock(Properties settings) {

View file

@ -10,7 +10,7 @@ import net.minecraft.core.Direction;
import net.minecraft.core.NonNullList;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.ContainerHelper;
@ -225,7 +225,7 @@ public class EndStoneSmelterBlockEntity extends BaseContainerBlockEntity impleme
@Override
protected Component getDefaultName() {
return new TranslatableComponent(String.format("block.%s.%s", BetterEnd.MOD_ID, EndStoneSmelter.ID));
return Component.translatable(String.format("block.%s.%s", BetterEnd.MOD_ID, EndStoneSmelter.ID));
}
@Override

View file

@ -4,9 +4,10 @@ import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.DimensionRenderingRegistry;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.Level;
import ru.bclib.BCLib;
@ -68,12 +69,13 @@ public class BetterEndClient implements ClientModInitializer {
if (player != null) {
hasSet = CrystaliteArmor.hasFullSet(player);
}
TranslatableComponent setDesc = new TranslatableComponent("tooltip.armor.crystalite_set");
MutableComponent setDesc = Component.translatable("tooltip.armor.crystalite_set");
setDesc.setStyle(Style.EMPTY.applyFormats(
hasSet ? ChatFormatting.BLUE : ChatFormatting.DARK_GRAY,
ChatFormatting.ITALIC
));
lines.add(TextComponent.EMPTY);
lines.add(Component.empty());
lines.add(setDesc);
}
});

View file

@ -120,7 +120,7 @@ public class Patterns {
public static Optional<String> createJson(ResourceLocation patternId, String parent, String block) {
ResourceManager resourceManager = Minecraft.getInstance().getResourceManager();
try (InputStream input = resourceManager.getResource(patternId).getInputStream()) {
try (InputStream input = resourceManager.getResource(patternId).get().open()) {
return Optional.ofNullable(createJson(new InputStreamReader(input, StandardCharsets.UTF_8), parent, block));
}
catch (Exception ex) {
@ -136,7 +136,7 @@ public class Patterns {
public static Optional<String> createJson(ResourceLocation patternId, Map<String, String> textures) {
ResourceManager resourceManager = Minecraft.getInstance().getResourceManager();
try (InputStream input = resourceManager.getResource(patternId).getInputStream()) {
try (InputStream input = resourceManager.getResource(patternId).get().open()) {
String json = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8)).lines()
.collect(Collectors.joining());
for (Entry<String, String> texture : textures.entrySet()) {

View file

@ -21,6 +21,8 @@ import ru.bclib.util.MHelper;
import ru.betterend.BetterEnd;
import java.util.Random;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.levelgen.LegacyRandomSource;
public class BetterEndSkyRenderer implements DimensionRenderingRegistry.SkyRenderer {
private static final ResourceLocation NEBULA_1 = BetterEnd.makeID("textures/sky/nebula_2.png");
@ -47,7 +49,7 @@ public class BetterEndSkyRenderer implements DimensionRenderingRegistry.SkyRende
private void initialise() {
if (!initialised) {
initStars();
Random random = new Random(131);
RandomSource random = new LegacyRandomSource(131);
axis1 = new Vector3f(random.nextFloat(), random.nextFloat(), random.nextFloat());
axis2 = new Vector3f(random.nextFloat(), random.nextFloat(), random.nextFloat());
axis3 = new Vector3f(random.nextFloat(), random.nextFloat(), random.nextFloat());
@ -182,8 +184,8 @@ public class BetterEndSkyRenderer implements DimensionRenderingRegistry.SkyRende
buffer = new VertexBuffer();
makeStars(bufferBuilder, minSize, maxSize, count, seed);
bufferBuilder.end();
buffer.upload(bufferBuilder);
BufferBuilder.RenderedBuffer renderedBuffer = bufferBuilder.end();
buffer.upload(renderedBuffer);
return buffer;
}
@ -195,8 +197,8 @@ public class BetterEndSkyRenderer implements DimensionRenderingRegistry.SkyRende
buffer = new VertexBuffer();
makeUVStars(bufferBuilder, minSize, maxSize, count, seed);
bufferBuilder.end();
buffer.upload(bufferBuilder);
BufferBuilder.RenderedBuffer renderedBuffer = bufferBuilder.end();
buffer.upload(renderedBuffer);
return buffer;
}
@ -208,8 +210,8 @@ public class BetterEndSkyRenderer implements DimensionRenderingRegistry.SkyRende
buffer = new VertexBuffer();
makeFarFog(bufferBuilder, minSize, maxSize, count, seed);
bufferBuilder.end();
buffer.upload(bufferBuilder);
BufferBuilder.RenderedBuffer renderedBuffer = bufferBuilder.end();
buffer.upload(renderedBuffer);
return buffer;
}
@ -221,8 +223,8 @@ public class BetterEndSkyRenderer implements DimensionRenderingRegistry.SkyRende
buffer = new VertexBuffer();
makeCylinder(bufferBuilder, 16, 50, 100);
bufferBuilder.end();
buffer.upload(bufferBuilder);
BufferBuilder.RenderedBuffer renderedBuffer = bufferBuilder.end();
buffer.upload(renderedBuffer);
return buffer;
}
@ -234,14 +236,14 @@ public class BetterEndSkyRenderer implements DimensionRenderingRegistry.SkyRende
buffer = new VertexBuffer();
makeCylinder(bufferBuilder, 16, 50, 70);
bufferBuilder.end();
buffer.upload(bufferBuilder);
BufferBuilder.RenderedBuffer renderedBuffer = bufferBuilder.end();
buffer.upload(renderedBuffer);
return buffer;
}
private void makeStars(BufferBuilder buffer, double minSize, double maxSize, int count, long seed) {
Random random = new Random(seed);
RandomSource random = new LegacyRandomSource(seed);
buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION);
for (int i = 0; i < count; ++i) {
@ -287,7 +289,7 @@ public class BetterEndSkyRenderer implements DimensionRenderingRegistry.SkyRende
}
private void makeUVStars(BufferBuilder buffer, double minSize, double maxSize, int count, long seed) {
Random random = new Random(seed);
RandomSource random = new LegacyRandomSource(seed);
buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
for (int i = 0; i < count; ++i) {
@ -336,7 +338,7 @@ public class BetterEndSkyRenderer implements DimensionRenderingRegistry.SkyRende
}
private void makeFarFog(BufferBuilder buffer, double minSize, double maxSize, int count, long seed) {
Random random = new Random(seed);
RandomSource random = new LegacyRandomSource(seed);
buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
for (int i = 0; i < count; ++i) {

View file

@ -44,6 +44,7 @@ import ru.betterend.util.GlobalState;
import java.util.EnumSet;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class EndSlimeEntity extends Slime {
private static final EntityDataAccessor<Byte> VARIANT = SynchedEntityData.defineId(
@ -212,7 +213,7 @@ public class EndSlimeEntity extends Slime {
return this.entityData.get(VARIANT) == 0;
}
public static boolean canSpawn(EntityType entityType, LevelAccessor world, MobSpawnType spawnType, BlockPos pos, Random random) {
public static boolean canSpawn(EntityType entityType, LevelAccessor world, MobSpawnType spawnType, BlockPos pos, RandomSource random) {
if (!world.getBlockState(pos.below()).is(CommonBlockTags.END_STONES)) {
return false;
}

View file

@ -17,11 +17,12 @@ import ru.betterend.integration.Integrations;
import java.util.List;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class BigEtherTreeFeature extends DefaultFeature {
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
final RandomSource random = featureConfig.random();
final BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
if (!world.getBlockState(pos.below()).is(CommonBlockTags.END_STONES)) return false;

View file

@ -29,13 +29,14 @@ import ru.betterend.integration.Integrations;
import java.util.List;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class NightshadeRedwoodTreeFeature extends DefaultFeature {
private static final List<Vector3f> BRANCH;
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
final RandomSource random = featureConfig.random();
final BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
if (!world.getBlockState(pos.below()).is(CommonBlockTags.END_STONES)) return false;

View file

@ -26,6 +26,7 @@ import ru.betterend.noise.OpenSimplexNoise;
import java.util.List;
import java.util.Random;
import net.minecraft.util.RandomSource;
import java.util.function.Function;
public class OldBulbisTreeFeature extends DefaultFeature {
@ -36,7 +37,7 @@ public class OldBulbisTreeFeature extends DefaultFeature {
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
final RandomSource random = featureConfig.random();
final BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
if (!world.getBlockState(pos.below()).is(CommonBlockTags.END_STONES)) return false;
@ -98,7 +99,7 @@ public class OldBulbisTreeFeature extends DefaultFeature {
return true;
}
private void bigSphere(WorldGenLevel world, BlockPos pos, float radius, BlockState cap, BlockState glow, BlockState wood, Function<BlockState, Boolean> replacement, Random random) {
private void bigSphere(WorldGenLevel world, BlockPos pos, float radius, BlockState cap, BlockState glow, BlockState wood, Function<BlockState, Boolean> replacement, RandomSource random) {
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
SDF sphere = new SDFSphere().setRadius(radius).setBlock(cap);
@ -145,7 +146,7 @@ public class OldBulbisTreeFeature extends DefaultFeature {
sphere.fillArea(world, pos, new AABB(pos.above((int) offsetY)).inflate(radius * 1.3F));
}
private void makeRoots(WorldGenLevel world, BlockPos pos, float radius, Random random, BlockState wood, Function<BlockState, Boolean> replacement) {
private void makeRoots(WorldGenLevel world, BlockPos pos, float radius, RandomSource random, BlockState wood, Function<BlockState, Boolean> replacement) {
int count = (int) (radius * 1.5F);
for (int i = 0; i < count; i++) {
float angle = (float) i / (float) count * MHelper.PI2;

View file

@ -35,7 +35,7 @@ public class REIAlloyingCategory implements DisplayCategory<REIAlloyingDisplay>
@Override
public @NotNull Component getTitle() {
return new TranslatableComponent(EndBlocks.END_STONE_SMELTER.getDescriptionId());
return Component.translatable(EndBlocks.END_STONE_SMELTER.getDescriptionId());
}
@Override
@ -55,7 +55,7 @@ public class REIAlloyingCategory implements DisplayCategory<REIAlloyingDisplay>
.animationDurationMS(10000));
widgets.add(Widgets.createLabel(
new Point(bounds.x + bounds.width - 5, bounds.y + 5),
new TranslatableComponent("category.rei.cooking.time&xp",
Component.translatable("category.rei.cooking.time&xp",
df.format(display.getXp()),
df.format(smeltTime / 20D)
)

View file

@ -99,7 +99,7 @@ public class REIAlloyingDisplay extends BasicDisplay implements SimpleGridMenuDi
.map(EntryStacks::of)
.map(e -> e.setting(
EntryStack.Settings.TOOLTIP_APPEND_EXTRA,
stack -> Collections.singletonList(new TranslatableComponent(
stack -> Collections.singletonList(Component.translatable(
"category.rei.smelting.fuel").withStyle(ChatFormatting.YELLOW))
))
.collect(Collectors.toList());

View file

@ -33,7 +33,7 @@ public class REIAlloyingFuelCategory implements DisplayCategory<REIAlloyingFuelD
@Override
public @NotNull Component getTitle() {
return new TranslatableComponent("category.rei.fuel");
return Component.translatable("category.rei.fuel");
}
@Override
@ -54,7 +54,7 @@ public class REIAlloyingFuelCategory implements DisplayCategory<REIAlloyingFuelD
widgets.add(Widgets.createRecipeBase(bounds));
widgets.add(Widgets.createLabel(
new Point(bounds.x + 26, bounds.getMaxY() - 15),
new TranslatableComponent("category.rei.fuel.time", burnTime)
Component.translatable("category.rei.fuel.time", burnTime)
).color(0xFF404040, 0xFFBBBBBB).noShadow().leftAligned());
widgets.add(Widgets.createBurningFire(new Point(bounds.x + 6, startPoint.y + 1))
.animationDurationTicks(recipeDisplay.getFuelTime()));
@ -72,7 +72,7 @@ public class REIAlloyingFuelCategory implements DisplayCategory<REIAlloyingFuelD
.disableHighlight();
String burnItems = DECIMAL_FORMAT.format(recipe.getFuelTime() / 200d);
return new DisplayRenderer() {
private TranslatableComponent text = new TranslatableComponent(
private TranslatableComponent text = Component.translatable(
"category.rei.fuel.time_short.items",
burnItems
);

View file

@ -39,7 +39,7 @@ public class REIAnvilCategory implements DisplayCategory<REIAnvilDisplay> {
@Override
public @NotNull Component getTitle() {
return new TranslatableComponent(Blocks.ANVIL.getDescriptionId());
return Component.translatable(Blocks.ANVIL.getDescriptionId());
}
@Override
@ -73,7 +73,7 @@ public class REIAnvilCategory implements DisplayCategory<REIAnvilDisplay> {
widgets.add(Widgets.createArrow(new Point(x + 24, y + 4)));
widgets.add(Widgets.createLabel(
new Point(bounds.x + bounds.width - 7, bounds.y + bounds.height - 15),
new TranslatableComponent("category.rei.damage.amount&dmg", display.getDamage())
Component.translatable("category.rei.damage.amount&dmg", display.getDamage())
).noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB));
widgets.add(Widgets.createSlot(new Point(x - 20, y + 4)).entries(materials).markInput());
widgets.add(Widgets.createSlot(new Point(x + 1, y + 4)).entries(inputEntries.get(0)).markInput());

View file

@ -35,7 +35,7 @@ public class REIInfusionCategory implements DisplayCategory<REIInfusionDisplay>
@Override
public @NotNull Component getTitle() {
return new TranslatableComponent(EndBlocks.INFUSION_PEDESTAL.getDescriptionId());
return Component.translatable(EndBlocks.INFUSION_PEDESTAL.getDescriptionId());
}
@Override
@ -98,7 +98,7 @@ public class REIInfusionCategory implements DisplayCategory<REIInfusionDisplay>
.markOutput());
widgets.add(Widgets.createLabel(
new Point(bounds.getMaxX() - 5, bounds.y + 6),
new TranslatableComponent("category.rei.infusion.time&val", display.getInfusionTime())
Component.translatable("category.rei.infusion.time&val", display.getInfusionTime())
).noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB));
return widgets;
}

View file

@ -1,8 +1,10 @@
package ru.betterend.item;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
@ -13,8 +15,8 @@ import ru.betterend.item.material.EndArmorMaterial;
public class CrystaliteArmor extends BaseArmorItem {
public final static TranslatableComponent CHEST_DESC;
public final static TranslatableComponent BOOTS_DESC;
public final static MutableComponent CHEST_DESC;
public final static MutableComponent BOOTS_DESC;
public CrystaliteArmor(EquipmentSlot equipmentSlot, Properties settings) {
super(EndArmorMaterial.CRYSTALITE, equipmentSlot, settings);
@ -37,9 +39,9 @@ public class CrystaliteArmor extends BaseArmorItem {
static {
Style descStyle = Style.EMPTY.applyFormats(ChatFormatting.DARK_AQUA, ChatFormatting.ITALIC);
CHEST_DESC = new TranslatableComponent("tooltip.armor.crystalite_chest");
CHEST_DESC = Component.translatable("tooltip.armor.crystalite_chest");
CHEST_DESC.setStyle(descStyle);
BOOTS_DESC = new TranslatableComponent("tooltip.armor.crystalite_boots");
BOOTS_DESC = Component.translatable("tooltip.armor.crystalite_boots");
BOOTS_DESC.setStyle(descStyle);
}
}

View file

@ -3,7 +3,7 @@ package ru.betterend.item;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.Component;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
@ -16,6 +16,7 @@ import ru.betterend.effects.EndStatusEffects;
import ru.betterend.interfaces.MobEffectApplier;
import ru.betterend.registry.EndItems;
import java.awt.*;
import java.util.List;
public class CrystaliteBoots extends CrystaliteArmor implements MobEffectApplier {
@ -35,7 +36,7 @@ public class CrystaliteBoots extends CrystaliteArmor implements MobEffectApplier
@Environment(EnvType.CLIENT)
public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> lines, TooltipFlag tooltip) {
super.appendHoverText(stack, level, lines, tooltip);
lines.add(1, TextComponent.EMPTY);
lines.add(1, Component.empty());
lines.add(2, BOOTS_DESC);
}
}

View file

@ -3,7 +3,7 @@ package ru.betterend.item;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.Component;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
@ -33,7 +33,7 @@ public class CrystaliteChestplate extends CrystaliteArmor implements MobEffectAp
@Environment(EnvType.CLIENT)
public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> lines, TooltipFlag tooltip) {
super.appendHoverText(stack, level, lines, tooltip);
lines.add(1, TextComponent.EMPTY);
lines.add(1, Component.empty());
lines.add(2, CHEST_DESC);
}
}

View file

@ -7,6 +7,7 @@ import net.minecraft.client.player.AbstractClientPlayer;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.network.protocol.game.ServerboundPlayerCommandPacket;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.player.ProfilePublicKey;
import net.minecraft.world.item.ElytraItem;
import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.Final;
@ -18,17 +19,20 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import ru.betterend.interfaces.FallFlyingItem;
import org.jetbrains.annotations.Nullable;
@Mixin(LocalPlayer.class)
public abstract class LocalPlayerMixin extends AbstractClientPlayer {
public LocalPlayerMixin(ClientLevel clientLevel, GameProfile gameProfile) {
super(clientLevel, gameProfile);
}
@Final
@Shadow
public ClientPacketListener connection;
public LocalPlayerMixin(ClientLevel clientLevel,
GameProfile gameProfile,
@Nullable ProfilePublicKey profilePublicKey) {
super(clientLevel, gameProfile, profilePublicKey);
}
@Inject(method = "aiStep", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;getItemBySlot(Lnet/minecraft/world/entity/EquipmentSlot;)Lnet/minecraft/world/item/ItemStack;", shift = Shift.AFTER))
public void be_aiStep(CallbackInfo info) {
ItemStack itemStack = getItemBySlot(EquipmentSlot.CHEST);

View file

@ -17,6 +17,7 @@ import ru.betterend.client.ClientOptions;
import ru.betterend.world.biome.EndBiome;
import java.util.Random;
import net.minecraft.util.RandomSource;
@Mixin(MusicManager.class)
public abstract class MusicTrackerMixin {
@ -26,7 +27,7 @@ public abstract class MusicTrackerMixin {
@Final
@Shadow
private Random random;
private RandomSource random;
@Shadow
private SoundInstance currentMusic;

View file

@ -38,7 +38,7 @@ public abstract class BlockBehaviourMixin {
info.setReturnValue(Lists.newArrayList(new ItemStack(Items.GLOWSTONE_DUST, max)));
}
}
count = MHelper.randRange(min, max, MHelper.RANDOM);
count = MHelper.randRange(min, max, MHelper.RANDOM_SOURCE);
info.setReturnValue(Lists.newArrayList(new ItemStack(Items.GLOWSTONE_DUST, count)));
}
}

View file

@ -26,6 +26,7 @@ import ru.betterend.registry.EndBlocks;
import ru.betterend.world.generator.GeneratorOptions;
import java.util.Random;
import net.minecraft.util.RandomSource;
@Mixin(value = ChorusFlowerBlock.class, priority = 100)
public abstract class ChorusFlowerBlockMixin extends Block {
@ -49,7 +50,7 @@ public abstract class ChorusFlowerBlockMixin extends Block {
}
@Inject(method = "randomTick", at = @At("HEAD"), cancellable = true)
private void be_randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random, CallbackInfo info) {
private void be_randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random, CallbackInfo info) {
if (world.getBlockState(pos.below()).is(CommonBlockTags.END_STONES)) {
BlockPos up = pos.above();
if (world.isEmptyBlock(up) && up.getY() < 256) {

View file

@ -18,12 +18,13 @@ import ru.bclib.util.MHelper;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
import net.minecraft.util.RandomSource;
@Mixin(ChorusPlantFeature.class)
public class ChorusPlantFeatureMixin {
@Inject(method = "place", at = @At("HEAD"), cancellable = true)
private void be_place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig, CallbackInfoReturnable<Boolean> info) {
final Random random = featureConfig.random();
final RandomSource random = featureConfig.random();
final BlockPos blockPos = featureConfig.origin();
final WorldGenLevel structureWorldAccess = featureConfig.level();
if (structureWorldAccess.isEmptyBlock(blockPos) && structureWorldAccess.getBlockState(blockPos.below()).is(EndBlocks.CHORUS_NYLIUM)) {

View file

@ -20,6 +20,7 @@ import ru.bclib.api.tag.CommonBlockTags;
import java.util.List;
import java.util.Random;
import net.minecraft.util.RandomSource;
@Mixin(EnchantmentMenu.class)
public abstract class EnchantmentMenuMixin extends AbstractContainerMenu {
@ -33,7 +34,7 @@ public abstract class EnchantmentMenuMixin extends AbstractContainerMenu {
@Final
@Shadow
private Random random;
private RandomSource random;
@Final
@Shadow

View file

@ -1,14 +1,18 @@
package ru.betterend.mixin.common;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.LevelHeightAccessor;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.WorldgenRandom;
import net.minecraft.world.level.levelgen.XoroshiroRandomSource;
import net.minecraft.world.level.levelgen.feature.EndCityFeature;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.structure.Structure;
import net.minecraft.world.level.levelgen.structure.pieces.PieceGenerator;
import net.minecraft.world.level.levelgen.structure.pieces.PieceGeneratorSupplier;
import net.minecraft.world.level.levelgen.structure.structures.EndCityStructure;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@ -18,33 +22,22 @@ import ru.betterend.world.generator.GeneratorOptions;
import java.util.Optional;
import java.util.Random;
import net.minecraft.util.RandomSource;
@Mixin(EndCityFeature.class)
@Mixin(EndCityStructure.class)
public class EndCityFeatureMixin {
@Inject(method = "pieceGeneratorSupplier", at = @At("HEAD"), cancellable = true)
private static void be_isFeatureChunk(PieceGeneratorSupplier.Context<NoneFeatureConfiguration> context, CallbackInfoReturnable<Optional<PieceGenerator<NoneFeatureConfiguration>>> info) {
@Inject(method = "findGenerationPoint", at = @At("HEAD"), cancellable = true)
private void be_findGenerationPoint(Structure.GenerationContext context,
CallbackInfoReturnable<Optional<Structure.GenerationStub>> info) {
final ChunkPos pos = context.chunkPos();
final ChunkGenerator chunkGenerator = context.chunkGenerator();
final LevelHeightAccessor levelHeightAccessor = context.heightAccessor();
Random chunkRandom = new WorldgenRandom(new XoroshiroRandomSource(pos.x, pos.z));
WorldgenRandom chunkRandom = new WorldgenRandom(new XoroshiroRandomSource(pos.x, pos.z));
if (GeneratorOptions.useNewGenerator()) {
int chance = GeneratorOptions.getEndCityFailChance();
if (chance == 0 || chunkRandom.nextInt(chance) == 0) {
if (!(getYPositionForFeature(pos, chunkGenerator, levelHeightAccessor) >= 60)){
info.cancel();
info.setReturnValue(Optional.empty());
}
}
else {
if (chance > 0 && chunkRandom.nextInt(chance) != 0) {
info.setReturnValue(Optional.empty());
info.cancel();
}
}
}
@Shadow
private static int getYPositionForFeature(ChunkPos pos, ChunkGenerator chunkGenerator, LevelHeightAccessor levelHeightAccessor) {
return 0;
}
}

View file

@ -25,6 +25,7 @@ import ru.betterend.world.generator.GeneratorOptions;
import java.util.Optional;
import java.util.Random;
import net.minecraft.util.RandomSource;
@Mixin(EndPodiumFeature.class)
public class EndPodiumFeatureMixin {
@ -41,7 +42,7 @@ public class EndPodiumFeatureMixin {
info.cancel();
}
else if (GeneratorOptions.replacePortal()) {
Random random = featurePlaceContext.random();
RandomSource random = featurePlaceContext.random();
WorldGenLevel world = featurePlaceContext.level();
BlockPos blockPos = be_updatePortalPos(world);
StructureTemplate structure = StructureHelper.readStructure(BetterEnd.makeID(active ? "portal/end_portal_active" : "portal/end_portal_inactive"));

View file

@ -14,11 +14,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.List;
import java.util.Random;
import net.minecraft.util.RandomSource;
@Mixin(Monster.class)
public class MonsterMixin {
@Inject(method = "checkMonsterSpawnRules", at = @At(value = "RETURN"), cancellable = true)
private static void be_checkMonsterSpawnRules(EntityType<? extends Monster> type, ServerLevelAccessor serverWorldAccess, MobSpawnType spawnReason, BlockPos pos, Random random, CallbackInfoReturnable<Boolean> info) {
private static void be_checkMonsterSpawnRules(EntityType<? extends Monster> type, ServerLevelAccessor serverWorldAccess, MobSpawnType spawnReason, BlockPos pos, RandomSource random, CallbackInfoReturnable<Boolean> info) {
boolean canSpawn = info.getReturnValue();
if (canSpawn && spawnReason == MobSpawnType.NATURAL && type == EntityType.ENDERMAN) {
AABB box = new AABB(pos).inflate(16);

View file

@ -57,9 +57,12 @@ public class NoiseChunkMixin implements BETargetChecker {
for (int cellXZ = 0; cellXZ < cellSizeXZ; ++cellXZ) {
int z = (firstCellZ + cellXZ) * sizeXZ;
for (NoiseChunk.NoiseInterpolator noiseInterpolator : this.interpolators) {
NoiseInterpolatorAccessor interpolator = (NoiseInterpolatorAccessor) noiseInterpolator;
final double[] ds = (primarySlice ? interpolator.be_getSlice0() : interpolator.be_getSlice1())[cellXZ];
TerrainGenerator.fillTerrainDensity(ds, x, z, sizeXZ, sizeY);
if (noiseInterpolator instanceof NoiseInterpolatorAccessor interpolator) {
final double[] ds = (primarySlice
? interpolator.be_getSlice0()
: interpolator.be_getSlice1())[cellXZ];
TerrainGenerator.fillTerrainDensity(ds, x, z, sizeXZ, sizeY);
}
}
}
}

View file

@ -13,8 +13,10 @@ import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.dimension.LevelStem;
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
import net.minecraft.world.level.storage.LevelStorageSource;
import net.minecraft.world.level.storage.LevelStorageSource.LevelStorageAccess;
import net.minecraft.world.level.storage.ServerLevelData;
import net.minecraft.world.level.storage.WritableLevelData;
@ -37,11 +39,18 @@ import java.util.function.Supplier;
@Mixin(ServerLevel.class)
public abstract class ServerLevelMixin extends Level {
protected ServerLevelMixin(WritableLevelData writableLevelData,
ResourceKey<Level> resourceKey,
Holder<DimensionType> holder,
Supplier<ProfilerFiller> supplier,
boolean bl,
boolean bl2,
long l,
int i) {
super(writableLevelData, resourceKey, holder, supplier, bl, bl2, l, i);
}
//private static String be_lastWorld = null;
protected ServerLevelMixin(WritableLevelData writableLevelData, ResourceKey<Level> resourceKey, Holder<DimensionType> dimensionType, Supplier<ProfilerFiller> supplier, boolean bl, boolean bl2, long l) {
super(writableLevelData, resourceKey, dimensionType, supplier, bl, bl2, l);
}
// @Inject(method = "<init>*", at = @At("TAIL"))
// private void be_onServerWorldInit(MinecraftServer server, Executor workerExecutor, LevelStorageSource.LevelStorageAccess session, ServerLevelData properties, ResourceKey<Level> registryKey, DimensionType dimensionType, ChunkProgressListener worldGenerationProgressListener, ChunkGenerator chunkGenerator, boolean debugWorld, long l, List<CustomSpawner> list, boolean bl, CallbackInfo info) {
@ -55,15 +64,27 @@ public abstract class ServerLevelMixin extends Level {
// }
@Inject(method = "<init>*", at = @At("TAIL"))
private void be_onServerWorldInit(MinecraftServer minecraftServer, Executor executor, LevelStorageAccess levelStorageAccess, ServerLevelData serverLevelData, ResourceKey resourceKey, Holder holder, ChunkProgressListener chunkProgressListener, ChunkGenerator chunkGenerator, boolean bl, long seed, List list, boolean bl2, CallbackInfo ci) {
private void be_onServerWorldInit(MinecraftServer minecraftServer,
Executor executor,
LevelStorageAccess levelStorageAccess,
ServerLevelData serverLevelData,
ResourceKey resourceKey,
LevelStem levelStem,
ChunkProgressListener chunkProgressListener,
boolean bl,
long seed,
List list,
boolean bl2,
CallbackInfo ci) {
ServerLevel level = ServerLevel.class.cast(this);
if (level.dimension() == Level.END) {
final ChunkGenerator chunkGenerator = levelStem.generator();
if (chunkGenerator instanceof NoiseBasedChunkGenerator) {
Holder<NoiseGeneratorSettings> sHolder = NoiseBasedChunkGeneratorAccessor.class.cast(chunkGenerator).be_getSettings();
BETargetChecker.class.cast(sHolder.value()).be_setTarget(true);
}
TerrainGenerator.initNoise(seed, chunkGenerator.getBiomeSource(), chunkGenerator.climateSampler());
TerrainGenerator.initNoise(seed, chunkGenerator.getBiomeSource(), level.getChunkSource().randomState().sampler());
}
}

View file

@ -17,6 +17,7 @@ import net.minecraft.server.players.PlayerList;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.player.ProfilePublicKey;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.biome.BiomeManager;
import net.minecraft.world.level.portal.PortalInfo;
@ -32,6 +33,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import ru.betterend.interfaces.TeleportingEntity;
import ru.betterend.world.generator.GeneratorOptions;
import org.jetbrains.annotations.Nullable;
@Mixin(ServerPlayer.class)
public abstract class ServerPlayerMixin extends Player implements TeleportingEntity {
@Shadow
@ -54,10 +57,15 @@ public abstract class ServerPlayerMixin extends Player implements TeleportingEnt
private BlockPos exitPos;
private int be_teleportDelay = 0;
public ServerPlayerMixin(Level world, BlockPos pos, float yaw, GameProfile profile) {
super(world, pos, yaw, profile);
public ServerPlayerMixin(Level level,
BlockPos blockPos,
float f,
GameProfile gameProfile,
@Nullable ProfilePublicKey profilePublicKey) {
super(level, blockPos, f, gameProfile, profilePublicKey);
}
@Inject(method = "createEndPlatform", at = @At("HEAD"), cancellable = true)
private void be_createEndSpawnPlatform(ServerLevel world, BlockPos centerPos, CallbackInfo info) {
if (!GeneratorOptions.generateObsidianPlatform()) {

View file

@ -29,6 +29,7 @@ import ru.betterend.BetterEnd;
import ru.betterend.world.generator.GeneratorOptions;
import java.util.Random;
import net.minecraft.util.RandomSource;
@Mixin(SpikeFeature.class)
public class SpikeFeatureMixin {
@ -40,7 +41,7 @@ public class SpikeFeatureMixin {
}
@Inject(method = "placeSpike", at = @At("HEAD"), cancellable = true)
private void be_placeSpike(ServerLevelAccessor world, Random random, SpikeConfiguration config, SpikeFeature.EndSpike spike, CallbackInfo info) {
private void be_placeSpike(ServerLevelAccessor world, RandomSource random, SpikeConfiguration config, SpikeFeature.EndSpike spike, CallbackInfo info) {
int x = spike.getCenterX();
int z = spike.getCenterZ();
int radius = spike.getRadius();

View file

@ -27,7 +27,7 @@ import ru.bclib.world.biomes.BCLBiome;
import ru.bclib.world.features.BCLFeature;
import ru.bclib.world.features.DefaultFeature;
import ru.bclib.world.features.ListFeature.StructureInfo;
import ru.bclib.world.features.NBTStructureFeature.TerrainMerge;
import ru.bclib.world.features.NBTFeature.TerrainMerge;
import ru.betterend.BetterEnd;
import ru.betterend.complexmaterials.StoneMaterial;
import ru.betterend.config.Configs;
@ -331,7 +331,8 @@ public class EndFeatures {
}
boolean hasCaves = bclbiome.getCustomData("has_caves", true) && !(bclbiome instanceof EndCaveBiome);
if (hasCaves && !BiomeAPI.END_VOID_BIOME_PICKER.containsImmutable(id)) {
//TODO: 1.19 Test Cave generation
if (hasCaves && !BiomeAPI.wasRegisteredAsEndVoidBiome(id) /*!BiomeAPI.END_VOID_BIOME_PICKER.containsImmutable(id)*/) {
if (Configs.BIOME_CONFIG.getBoolean(id, "hasCaves", true)) {
BiomeAPI.addBiomeFeature(biome, ROUND_CAVE);
BiomeAPI.addBiomeFeature(biome, TUNEL_CAVE);

View file

@ -7,7 +7,7 @@ import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.levelgen.GenerationStep.Decoration;
import net.minecraft.world.level.levelgen.structure.pieces.StructurePieceType;
import ru.bclib.api.tag.TagAPI;
import ru.bclib.world.structures.BCLStructureFeature;
import ru.bclib.world.structures.BCLStructure;
import ru.betterend.BetterEnd;
import ru.betterend.world.structures.features.EternalPortalStructure;
import ru.betterend.world.structures.features.GiantIceStarStructure;
@ -31,51 +31,51 @@ public class EndStructures {
public static final StructurePieceType PAINTED_MOUNTAIN_PIECE = register("painted_mountain_piece", PaintedMountainPiece::new);
public static final StructurePieceType NBT_PIECE = register("nbt_piece", NBTPiece::new);
public static final BCLStructureFeature GIANT_MOSSY_GLOWSHROOM = new BCLStructureFeature(
public static final BCLStructure<GiantMossyGlowshroomStructure> GIANT_MOSSY_GLOWSHROOM = new BCLStructure(
BetterEnd.makeID("giant_mossy_glowshroom"),
new GiantMossyGlowshroomStructure(),
GiantMossyGlowshroomStructure::new,
Decoration.SURFACE_STRUCTURES,
16,
8
);
public static final BCLStructureFeature MEGALAKE = new BCLStructureFeature(
public static final BCLStructure<MegaLakeStructure> MEGALAKE = new BCLStructure(
BetterEnd.makeID("megalake"),
new MegaLakeStructure(),
MegaLakeStructure::new,
Decoration.RAW_GENERATION,
4,
1
);
public static final BCLStructureFeature MEGALAKE_SMALL = new BCLStructureFeature(
public static final BCLStructure<MegaLakeSmallStructure> MEGALAKE_SMALL = new BCLStructure(
BetterEnd.makeID("megalake_small"),
new MegaLakeSmallStructure(),
MegaLakeSmallStructure::new,
Decoration.RAW_GENERATION,
4,
1
);
public static final BCLStructureFeature MOUNTAIN = new BCLStructureFeature(
public static final BCLStructure<MountainStructure> MOUNTAIN = new BCLStructure(
BetterEnd.makeID("mountain"),
new MountainStructure(),
MountainStructure::new,
Decoration.RAW_GENERATION,
3,
2
);
public static final BCLStructureFeature PAINTED_MOUNTAIN = new BCLStructureFeature(
public static final BCLStructure<PaintedMountainStructure> PAINTED_MOUNTAIN = new BCLStructure(
BetterEnd.makeID("painted_mountain"),
new PaintedMountainStructure(),
PaintedMountainStructure::new,
Decoration.RAW_GENERATION,
3,
2
);
public static final BCLStructureFeature ETERNAL_PORTAL = new BCLStructureFeature(
public static final BCLStructure<EternalPortalStructure> ETERNAL_PORTAL = new BCLStructure(
BetterEnd.makeID("eternal_portal"),
new EternalPortalStructure(),
EternalPortalStructure::new,
Decoration.SURFACE_STRUCTURES,
16,
6
);
public static final BCLStructureFeature GIANT_ICE_STAR = new BCLStructureFeature(
public static final BCLStructure<GiantIceStarStructure> GIANT_ICE_STAR = new BCLStructure(
BetterEnd.makeID("giant_ice_star"),
new GiantIceStarStructure(),
GiantIceStarStructure::new,
Decoration.SURFACE_STRUCTURES,
16,
8

View file

@ -25,6 +25,7 @@ import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.chunk.LevelChunkSection;
import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.LegacyRandomSource;
import net.minecraft.world.level.material.Material;
import org.jetbrains.annotations.Nullable;
import ru.bclib.blocks.BlockProperties;
@ -40,6 +41,7 @@ import java.awt.Point;
import java.util.List;
import java.util.Objects;
import java.util.Random;
import net.minecraft.util.RandomSource;
import java.util.Set;
import java.util.function.Predicate;
@ -444,7 +446,7 @@ public class EternalRitual {
net.minecraft.data.worldgen.features.EndFeatures.END_ISLAND.value().place(
targetWorld,
targetWorld.getChunkSource().getGenerator(),
new Random(basePos.asLong()),
new LegacyRandomSource(basePos.asLong()),
basePos.below()
);
}
@ -456,7 +458,7 @@ public class EternalRitual {
.value()
.place(targetWorld,
targetWorld.getChunkSource().getGenerator(),
new Random(basePos.asLong()),
new LegacyRandomSource(basePos.asLong()),
basePos.below()
);
generatePortal(targetWorld, basePos, portalAxis, portalId);

View file

@ -1,7 +1,9 @@
package ru.betterend.util;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
public class LangUtil {
public final static String CONFIG_ELEMENT = "configuration";
@ -20,7 +22,7 @@ public class LangUtil {
return getString(element, key);
}
public TranslatableComponent getText(String key) {
public MutableComponent getText(String key) {
return getText(element, key);
}
@ -32,7 +34,7 @@ public class LangUtil {
return translate(String.format("%s.%s", element, key));
}
public static TranslatableComponent getText(String element, String key) {
return new TranslatableComponent(getString(element, key));
public static MutableComponent getText(String element, String key) {
return Component.translatable(getString(element, key));
}
}

View file

@ -5,6 +5,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
@ -16,12 +17,13 @@ import ru.bclib.util.BlocksHelper;
import ru.bclib.util.MHelper;
import java.util.Random;
import net.minecraft.util.RandomSource;
import java.util.Set;
public class StructureErode {
private static final Direction[] DIR = BlocksHelper.makeHorizontal();
public static void erode(WorldGenLevel world, BoundingBox bounds, int iterations, Random random) {
public static void erode(WorldGenLevel world, BoundingBox bounds, int iterations, RandomSource random) {
MutableBlockPos mut = new MutableBlockPos();
boolean canDestruct = true;
for (int i = 0; i < iterations; i++) {
@ -132,7 +134,7 @@ public class StructureErode {
}
}
public static void erodeIntense(WorldGenLevel world, BoundingBox bounds, Random random) {
public static void erodeIntense(WorldGenLevel world, BoundingBox bounds, RandomSource random) {
MutableBlockPos mut = new MutableBlockPos();
MutableBlockPos mut2 = new MutableBlockPos();
int minY = bounds.minY() - 10;
@ -256,7 +258,7 @@ public class StructureErode {
return false;
}
public static void cover(WorldGenLevel world, BoundingBox bounds, Random random, BlockState defaultBlock) {
public static void cover(WorldGenLevel world, BoundingBox bounds, RandomSource random, BlockState defaultBlock) {
MutableBlockPos mut = new MutableBlockPos();
for (int x = bounds.minX(); x <= bounds.maxX(); x++) {
mut.setX(x);

View file

@ -103,7 +103,6 @@ public class EndBiome extends BCLBiome implements SurfaceMaterialProvider {
public static EndBiome create(Config biomeConfig){
BCLBiomeBuilder builder = BCLBiomeBuilder
.start(biomeConfig.ID)
.category(Biome.BiomeCategory.THEEND)
.music(SoundEvents.MUSIC_END)
.waterColor(4159204)
.waterFogColor(329011)

View file

@ -3,7 +3,6 @@ package ru.betterend.world.biome.cave;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.Biome.BiomeCategory;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.GenerationStep;
import net.minecraft.world.level.levelgen.feature.Feature;
@ -20,6 +19,7 @@ import ru.betterend.world.biome.EndBiome;
import ru.betterend.world.features.terrain.caves.CaveChunkPopulatorFeature;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class EndCaveBiome extends EndBiome {
public static abstract class Config extends EndBiome.Config {
@ -35,8 +35,7 @@ public class EndCaveBiome extends EndBiome {
new CaveChunkPopulatorFeature(() -> (EndCaveBiome) BiomeAPI.getBiome(ID))
);
builder.category(BiomeCategory.NONE)
.feature(feature)
builder.feature(feature)
.music(EndSounds.MUSIC_CAVES)
.loop(EndSounds.AMBIENT_CAVES);
}
@ -67,11 +66,11 @@ public class EndCaveBiome extends EndBiome {
ceilFeatures.add(feature, weight);
}
public Feature<?> getFloorFeature(Random random) {
public Feature<?> getFloorFeature(RandomSource random) {
return floorFeatures.isEmpty() ? null : floorFeatures.get(random);
}
public Feature<?> getCeilFeature(Random random) {
public Feature<?> getCeilFeature(RandomSource random) {
return ceilFeatures.isEmpty() ? null : ceilFeatures.get(random);
}

View file

@ -8,6 +8,7 @@ import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class BlueVineFeature extends ScatterFeature {
private boolean small;
@ -18,7 +19,7 @@ public class BlueVineFeature extends ScatterFeature {
@Override
@SuppressWarnings("deprecation")
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
public boolean canGenerate(WorldGenLevel world, RandomSource random, BlockPos center, BlockPos blockPos, float radius) {
float d = MHelper.length(
center.getX() - blockPos.getX(),
center.getZ() - blockPos.getZ()
@ -28,7 +29,7 @@ public class BlueVineFeature extends ScatterFeature {
}
@Override
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, RandomSource random, BlockPos blockPos) {
if (small) {
BlocksHelper.setWithoutUpdate(
world,

View file

@ -19,6 +19,7 @@ import ru.betterend.util.LootTableUtil;
import java.util.List;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class BuildingListFeature extends ListFeature {
public BuildingListFeature(List<StructureInfo> list, BlockState defaultBlock) {
@ -37,7 +38,7 @@ public class BuildingListFeature extends ListFeature {
public StructureTemplate.StructureBlockInfo processBlock(LevelReader levelReader, BlockPos blockPos, BlockPos blockPos2, StructureBlockInfo structureBlockInfo, StructureBlockInfo structureBlockInfo2, StructurePlaceSettings structurePlaceSettings) {
BlockState blockState = structureBlockInfo2.state;
if (blockState.getBlock() instanceof ChestBlock) {
Random random = structurePlaceSettings.getRandom(structureBlockInfo2.pos);
RandomSource random = structurePlaceSettings.getRandom(structureBlockInfo2.pos);
BlockPos chestPos = structureBlockInfo2.pos;
ChestBlock chestBlock = ChestBlock.class.cast(blockState.getBlock());
BlockEntity entity = chestBlock.newBlockEntity(chestPos, blockState);

View file

@ -11,11 +11,12 @@ import ru.betterend.blocks.EndBlockProperties;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class CavePumpkinFeature extends DefaultFeature {
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
final RandomSource random = featureConfig.random();
final BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
if (!world.getBlockState(pos.above()).is(CommonBlockTags.GEN_END_STONES) || !world.isEmptyBlock(pos) || !world.isEmptyBlock(

View file

@ -2,6 +2,7 @@ package ru.betterend.world.features;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
@ -21,14 +22,15 @@ import net.minecraft.world.level.material.Material;
import ru.bclib.api.tag.CommonBlockTags;
import ru.bclib.util.MHelper;
import ru.bclib.util.StructureHelper;
import ru.bclib.world.features.NBTStructureFeature;
import ru.bclib.world.features.NBTFeature;
import ru.betterend.util.BlockFixer;
import ru.betterend.util.StructureErode;
import ru.betterend.world.biome.EndBiome;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class CrashedShipFeature extends NBTStructureFeature {
public class CrashedShipFeature extends NBTFeature {
private static final StructureProcessor REPLACER;
private static final String STRUCTURE_PATH = "/data/minecraft/structures/end_city/ship.nbt";
private StructureTemplate structure;
@ -38,7 +40,7 @@ public class CrashedShipFeature extends NBTStructureFeature {
}
@Override
protected StructureTemplate getStructure(WorldGenLevel world, BlockPos pos, Random random) {
protected StructureTemplate getStructure(WorldGenLevel world, BlockPos pos, RandomSource random) {
if (structure == null) {
structure = world.getLevel().getStructureManager().getOrCreate(new ResourceLocation("end_city/ship"));
if (structure == null) {
@ -49,7 +51,7 @@ public class CrashedShipFeature extends NBTStructureFeature {
}
@Override
protected boolean canSpawn(WorldGenLevel world, BlockPos pos, Random random) {
protected boolean canSpawn(WorldGenLevel world, BlockPos pos, RandomSource random) {
long x = pos.getX() >> 4;
long z = pos.getX() >> 4;
if (x * x + z * z < 3600) {
@ -59,30 +61,30 @@ public class CrashedShipFeature extends NBTStructureFeature {
}
@Override
protected Rotation getRotation(WorldGenLevel world, BlockPos pos, Random random) {
protected Rotation getRotation(WorldGenLevel world, BlockPos pos, RandomSource random) {
return Rotation.getRandom(random);
}
@Override
protected Mirror getMirror(WorldGenLevel world, BlockPos pos, Random random) {
protected Mirror getMirror(WorldGenLevel world, BlockPos pos, RandomSource random) {
return Mirror.values()[random.nextInt(3)];
}
@Override
protected int getYOffset(StructureTemplate structure, WorldGenLevel world, BlockPos pos, Random random) {
protected int getYOffset(StructureTemplate structure, WorldGenLevel world, BlockPos pos, RandomSource random) {
int min = structure.getSize().getY() >> 3;
int max = structure.getSize().getY() >> 2;
return -MHelper.randRange(min, max, random);
}
@Override
protected TerrainMerge getTerrainMerge(WorldGenLevel world, BlockPos pos, Random random) {
protected TerrainMerge getTerrainMerge(WorldGenLevel world, BlockPos pos, RandomSource random) {
return TerrainMerge.NONE;
}
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
final RandomSource random = featureConfig.random();
BlockPos center = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
center = new BlockPos(((center.getX() >> 4) << 4) | 8, 128, ((center.getZ() >> 4) << 4) | 8);

View file

@ -9,6 +9,7 @@ import ru.bclib.util.BlocksHelper;
import ru.bclib.util.MHelper;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class DoublePlantFeature extends ScatterFeature {
private final Block smallPlant;
@ -22,7 +23,7 @@ public class DoublePlantFeature extends ScatterFeature {
}
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
public boolean canGenerate(WorldGenLevel world, RandomSource random, BlockPos center, BlockPos blockPos, float radius) {
float d = MHelper.length(
center.getX() - blockPos.getX(),
center.getZ() - blockPos.getZ()
@ -32,7 +33,7 @@ public class DoublePlantFeature extends ScatterFeature {
}
@Override
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, RandomSource random, BlockPos blockPos) {
if (plant instanceof BaseDoublePlantBlock) {
int rot = random.nextInt(4);
BlockState state = plant.defaultBlockState().setValue(BaseDoublePlantBlock.ROTATION, rot);

View file

@ -6,6 +6,7 @@ import ru.betterend.blocks.EndLilySeedBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class EndLilyFeature extends UnderwaterPlantScatter {
public EndLilyFeature(int radius) {
@ -13,7 +14,7 @@ public class EndLilyFeature extends UnderwaterPlantScatter {
}
@Override
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, RandomSource random, BlockPos blockPos) {
EndLilySeedBlock seed = (EndLilySeedBlock) EndBlocks.END_LILY_SEED;
seed.grow(world, random, blockPos);
}

View file

@ -6,6 +6,7 @@ import ru.betterend.blocks.EndLotusSeedBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class EndLotusFeature extends UnderwaterPlantScatter {
public EndLotusFeature(int radius) {
@ -13,7 +14,7 @@ public class EndLotusFeature extends UnderwaterPlantScatter {
}
@Override
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, RandomSource random, BlockPos blockPos) {
EndLotusSeedBlock seed = (EndLotusSeedBlock) EndBlocks.END_LOTUS_SEED;
seed.grow(world, random, blockPos);
}

View file

@ -12,6 +12,7 @@ import ru.betterend.blocks.EndLotusLeafBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class EndLotusLeafFeature extends ScatterFeature {
public EndLotusLeafFeature(int radius) {
@ -19,7 +20,7 @@ public class EndLotusLeafFeature extends ScatterFeature {
}
@Override
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, RandomSource random, BlockPos blockPos) {
if (canGenerate(world, blockPos)) {
generateLeaf(world, blockPos);
}
@ -74,7 +75,7 @@ public class EndLotusLeafFeature extends ScatterFeature {
}
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
public boolean canGenerate(WorldGenLevel world, RandomSource random, BlockPos center, BlockPos blockPos, float radius) {
return world.isEmptyBlock(blockPos) && world.getBlockState(blockPos.below()).is(Blocks.WATER);
}
}

View file

@ -12,6 +12,7 @@ import ru.bclib.util.MHelper;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class FilaluxFeature extends SkyScatterFeature {
public FilaluxFeature() {
@ -19,7 +20,7 @@ public class FilaluxFeature extends SkyScatterFeature {
}
@Override
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, RandomSource random, BlockPos blockPos) {
BlockState vine = EndBlocks.FILALUX.defaultBlockState();
BlockState wings = EndBlocks.FILALUX_WINGS.defaultBlockState();
BlocksHelper.setWithoutUpdate(world, blockPos, EndBlocks.FILALUX_LANTERN);

View file

@ -12,6 +12,7 @@ import ru.bclib.world.features.DefaultFeature;
import ru.betterend.util.GlobalState;
import java.util.Random;
import net.minecraft.util.RandomSource;
public abstract class FullHeightScatterFeature extends DefaultFeature {
private final int radius;
@ -20,14 +21,14 @@ public abstract class FullHeightScatterFeature extends DefaultFeature {
this.radius = radius;
}
public abstract boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius);
public abstract boolean canGenerate(WorldGenLevel world, RandomSource random, BlockPos center, BlockPos blockPos, float radius);
public abstract void generate(WorldGenLevel world, Random random, BlockPos blockPos);
public abstract void generate(WorldGenLevel world, RandomSource random, BlockPos blockPos);
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final MutableBlockPos POS = GlobalState.stateForThread().POS;
final Random random = featureConfig.random();
final RandomSource random = featureConfig.random();
final BlockPos center = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
int maxY = world.getHeight(Heightmap.Types.WORLD_SURFACE_WG, center.getX(), center.getZ());

View file

@ -6,6 +6,7 @@ import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class GlowPillarFeature extends ScatterFeature {
public GlowPillarFeature() {
@ -13,12 +14,12 @@ public class GlowPillarFeature extends ScatterFeature {
}
@Override
public boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius) {
public boolean canGenerate(WorldGenLevel world, RandomSource random, BlockPos center, BlockPos blockPos, float radius) {
return EndBlocks.GLOWING_PILLAR_SEED.canSurvive(AIR, world, blockPos);
}
@Override
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, RandomSource random, BlockPos blockPos) {
EndPlantWithAgeBlock seed = ((EndPlantWithAgeBlock) EndBlocks.GLOWING_PILLAR_SEED);
seed.growAdult(world, random, blockPos);
}

View file

@ -6,6 +6,7 @@ import ru.betterend.blocks.HydraluxSaplingBlock;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
import net.minecraft.util.RandomSource;
public class HydraluxFeature extends UnderwaterPlantScatter {
public HydraluxFeature(int radius) {
@ -13,7 +14,7 @@ public class HydraluxFeature extends UnderwaterPlantScatter {
}
@Override
public void generate(WorldGenLevel world, Random random, BlockPos blockPos) {
public void generate(WorldGenLevel world, RandomSource random, BlockPos blockPos) {
HydraluxSaplingBlock seed = (HydraluxSaplingBlock) EndBlocks.HYDRALUX_SAPLING;
seed.grow(world, random, blockPos);
}

View file

@ -12,6 +12,7 @@ import ru.bclib.world.features.DefaultFeature;
import ru.betterend.util.GlobalState;
import java.util.Random;
import net.minecraft.util.RandomSource;
public abstract class InvertedScatterFeature extends DefaultFeature {
private final int radius;
@ -20,14 +21,14 @@ public abstract class InvertedScatterFeature extends DefaultFeature {
this.radius = radius;
}
public abstract boolean canGenerate(WorldGenLevel world, Random random, BlockPos center, BlockPos blockPos, float radius);
public abstract boolean canGenerate(WorldGenLevel world, RandomSource random, BlockPos center, BlockPos blockPos, float radius);
public abstract void generate(WorldGenLevel world, Random random, BlockPos blockPos);
public abstract void generate(WorldGenLevel world, RandomSource random, BlockPos blockPos);
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final MutableBlockPos POS = GlobalState.stateForThread().POS;
final Random random = featureConfig.random();
final RandomSource random = featureConfig.random();
final BlockPos center = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
int maxY = world.getHeight(Heightmap.Types.WORLD_SURFACE, center.getX(), center.getZ());

Some files were not shown because too many files have changed in this diff Show more