Start migration

This commit is contained in:
Aleksey 2021-04-08 21:55:07 +03:00
parent 6630ce0cab
commit 47ed597358
491 changed files with 12045 additions and 11953 deletions

View file

@ -11,20 +11,20 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.ChorusFlowerBlock;
import net.minecraft.block.ChorusPlantBlock;
import net.minecraft.block.ShapeContext;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.ChorusFlowerBlock;
import net.minecraft.world.level.block.ChorusPlantBlock;
import net.minecraft.world.level.block.ShapeContext;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.WorldView;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndTags;
@ -35,75 +35,80 @@ import ru.betterend.world.generator.GeneratorOptions;
public abstract class ChorusFlowerBlockMixin extends Block {
private static final VoxelShape SHAPE_FULL = Block.createCuboidShape(0, 0, 0, 16, 16, 16);
private static final VoxelShape SHAPE_HALF = Block.createCuboidShape(0, 0, 0, 16, 4, 16);
public ChorusFlowerBlockMixin(Settings settings) {
public ChorusFlowerBlockMixin(Properties settings) {
super(settings);
}
@Shadow
@Final
private ChorusPlantBlock plantBlock;
@Inject(method = "canPlaceAt", at = @At("HEAD"), cancellable = true)
private void beCanPlace(BlockState state, WorldView world, BlockPos pos, CallbackInfoReturnable<Boolean> info) {
if (world.getBlockState(pos.down()).isOf(EndBlocks.CHORUS_NYLIUM)) {
if (world.getBlockState(pos.below()).is(EndBlocks.CHORUS_NYLIUM)) {
info.setReturnValue(true);
info.cancel();
}
}
@Inject(method = "randomTick", at = @At("HEAD"), cancellable = true)
private void beOnTick(BlockState state, ServerWorld world, BlockPos pos, Random random, CallbackInfo info) {
if (world.getBlockState(pos.down()).isIn(EndTags.END_GROUND)) {
private void beOnTick(BlockState state, ServerLevel world, BlockPos pos, Random random, CallbackInfo info) {
if (world.getBlockState(pos.below()).isIn(EndTags.END_GROUND)) {
BlockPos up = pos.up();
if (world.isAir(up) && up.getY() < 256) {
int i = state.get(ChorusFlowerBlock.AGE);
int i = state.getValue(ChorusFlowerBlock.AGE);
if (i < 5) {
this.grow(world, up, i + 1);
if (GeneratorOptions.changeChorusPlant()) {
BlocksHelper.setWithoutUpdate(world, pos, plantBlock.getDefaultState().with(ChorusPlantBlock.UP, true).with(ChorusPlantBlock.DOWN, true).with(BlocksHelper.ROOTS, true));
}
else {
BlocksHelper.setWithoutUpdate(world, pos, plantBlock.getDefaultState().with(ChorusPlantBlock.UP, true).with(ChorusPlantBlock.DOWN, true));
BlocksHelper.setWithoutUpdate(world, pos,
plantBlock.defaultBlockState().with(ChorusPlantBlock.UP, true)
.with(ChorusPlantBlock.DOWN, true).with(BlocksHelper.ROOTS, true));
} else {
BlocksHelper.setWithoutUpdate(world, pos, plantBlock.defaultBlockState()
.with(ChorusPlantBlock.UP, true).with(ChorusPlantBlock.DOWN, true));
}
info.cancel();
}
}
}
}
@Inject(method = "generate", at = @At("RETURN"), cancellable = true)
private static void beOnGenerate(WorldAccess world, BlockPos pos, Random random, int size, CallbackInfo info) {
private static void beOnGenerate(LevelAccessor world, BlockPos pos, Random random, int size, CallbackInfo info) {
BlockState state = world.getBlockState(pos);
if (GeneratorOptions.changeChorusPlant() && state.isOf(Blocks.CHORUS_PLANT)) {
if (GeneratorOptions.changeChorusPlant() && state.is(Blocks.CHORUS_PLANT)) {
BlocksHelper.setWithoutUpdate(world, pos, state.with(BlocksHelper.ROOTS, true));
}
}
@Shadow
private static boolean isSurroundedByAir(WorldView world, BlockPos pos, @Nullable Direction exceptDirection) { return false; }
private static boolean isSurroundedByAir(WorldView world, BlockPos pos, @Nullable Direction exceptDirection) {
return false;
}
@Shadow
private void grow(World world, BlockPos pos, int age) {}
private void grow(Level world, BlockPos pos, int age) {
}
@Shadow
private void die(World world, BlockPos pos) {}
private void die(Level world, BlockPos pos) {
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
if (GeneratorOptions.changeChorusPlant()) {
return state.get(ChorusFlowerBlock.AGE) == 5 ? SHAPE_HALF : SHAPE_FULL;
}
else {
return state.getValue(ChorusFlowerBlock.AGE) == 5 ? SHAPE_HALF : SHAPE_FULL;
} else {
return super.getOutlineShape(state, world, pos, context);
}
}
@Inject(method = "die", at = @At("HEAD"), cancellable = true)
private void beOnDie(World world, BlockPos pos, CallbackInfo info) {
BlockState down = world.getBlockState(pos.down());
if (down.isOf(Blocks.CHORUS_PLANT) || down.isIn(EndTags.GEN_TERRAIN)) {
world.setBlockState(pos, this.getDefaultState().with(Properties.AGE_5, 5), 2);
private void beOnDie(Level world, BlockPos pos, CallbackInfo info) {
BlockState down = world.getBlockState(pos.below());
if (down.is(Blocks.CHORUS_PLANT) || down.isIn(EndTags.GEN_TERRAIN)) {
world.setBlockAndUpdate(pos, this.defaultBlockState().with(Properties.AGE_5, 5), 2);
world.syncWorldEvent(1034, pos, 0);
}
info.cancel();