Continue mapping migration
This commit is contained in:
parent
99ade39404
commit
f03fd03bd0
499 changed files with 12567 additions and 12723 deletions
|
@ -5,52 +5,51 @@ import java.util.Random;
|
|||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
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.material.MaterialColor;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import ru.betterend.blocks.basis.BlockBase;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
|
||||
public class BrimstoneBlock extends BlockBase {
|
||||
public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVE;
|
||||
|
||||
|
||||
public BrimstoneBlock() {
|
||||
super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(MaterialColor.COLOR_BROWN).ticksRandomly());
|
||||
setDefaultState(stateManager.defaultBlockState().with(ACTIVATED, false));
|
||||
super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(MaterialColor.COLOR_BROWN).randomTicks());
|
||||
registerDefaultState(stateDefinition.any().setValue(ACTIVATED, false));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateManager) {
|
||||
stateManager.add(ACTIVATED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlaced(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer,
|
||||
ItemStack itemStack) {
|
||||
public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) {
|
||||
if (world.isClientSide()) {
|
||||
updateChunks((ClientLevel) world, pos);
|
||||
}
|
||||
}
|
||||
|
||||
public void onBroken(LevelAccessor world, BlockPos pos, BlockState state) {
|
||||
|
||||
public void destroy(LevelAccessor world, BlockPos pos, BlockState state) {
|
||||
if (world.isClientSide()) {
|
||||
updateChunks((ClientLevel) world, pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void updateChunks(ClientLevel world, BlockPos pos) {
|
||||
int y = pos.getY() >> 4;
|
||||
int x1 = (pos.getX() - 2) >> 4;
|
||||
|
@ -59,41 +58,45 @@ public class BrimstoneBlock extends BlockBase {
|
|||
int z2 = (pos.getZ() + 2) >> 4;
|
||||
for (int x = x1; x <= x2; x++) {
|
||||
for (int z = z1; z <= z2; z++) {
|
||||
world.scheduleBlockRenders(x, y, z);
|
||||
world.setSectionDirtyWithNeighbors(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void scheduledTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
|
||||
public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
|
||||
boolean deactivate = true;
|
||||
for (Direction dir : BlocksHelper.DIRECTIONS) {
|
||||
if (world.getFluidState(pos.relative(dir)).getFluid().equals(Fluids.WATER)) {
|
||||
for (Direction dir: BlocksHelper.DIRECTIONS) {
|
||||
if (world.getFluidState(pos.relative(dir)).getType().equals(Fluids.WATER)) {
|
||||
deactivate = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (state.getValue(ACTIVATED)) {
|
||||
if (deactivate) {
|
||||
world.setBlockAndUpdate(pos, getDefaultState().with(ACTIVATED, false));
|
||||
} else if (state.getValue(ACTIVATED) && random.nextInt(16) == 0) {
|
||||
world.setBlockAndUpdate(pos, defaultBlockState().setValue(ACTIVATED, false));
|
||||
}
|
||||
else if (state.getValue(ACTIVATED) && random.nextInt(16) == 0) {
|
||||
Direction dir = BlocksHelper.randomDirection(random);
|
||||
BlockPos side = pos.relative(dir);
|
||||
BlockState sideState = world.getBlockState(side);
|
||||
if (sideState.getBlock() instanceof SulphurCrystalBlock) {
|
||||
if (sideState.get(SulphurCrystalBlock.AGE) < 2 && sideState.get(SulphurCrystalBlock.WATERLOGGED)) {
|
||||
int age = sideState.get(SulphurCrystalBlock.AGE) + 1;
|
||||
world.setBlockAndUpdate(side, sideState.with(SulphurCrystalBlock.AGE, age));
|
||||
if (sideState.getValue(SulphurCrystalBlock.AGE) < 2 && sideState.getValue(SulphurCrystalBlock.WATERLOGGED)) {
|
||||
int age = sideState.getValue(SulphurCrystalBlock.AGE) + 1;
|
||||
world.setBlockAndUpdate(side, sideState.setValue(SulphurCrystalBlock.AGE, age));
|
||||
}
|
||||
} else if (sideState.getFluidState().getFluid() == Fluids.WATER) {
|
||||
}
|
||||
else if (sideState.getFluidState().getType() == Fluids.WATER) {
|
||||
BlockState crystal = EndBlocks.SULPHUR_CRYSTAL.defaultBlockState()
|
||||
.with(SulphurCrystalBlock.FACING, dir).with(SulphurCrystalBlock.WATERLOGGED, true)
|
||||
.with(SulphurCrystalBlock.AGE, 0);
|
||||
.setValue(SulphurCrystalBlock.FACING, dir)
|
||||
.setValue(SulphurCrystalBlock.WATERLOGGED, true)
|
||||
.setValue(SulphurCrystalBlock.AGE, 0);
|
||||
world.setBlockAndUpdate(side, crystal);
|
||||
}
|
||||
}
|
||||
} else if (!deactivate && !state.getValue(ACTIVATED)) {
|
||||
world.setBlockAndUpdate(pos, getDefaultState().with(ACTIVATED, true));
|
||||
}
|
||||
else if (!deactivate && !state.getValue(ACTIVATED)) {
|
||||
world.setBlockAndUpdate(pos, defaultBlockState().setValue(ACTIVATED, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue