Menger sponge, translation, fixes

This commit is contained in:
paulevsGitch 2020-12-06 13:41:24 +03:00
parent fd0d49391d
commit 1195ca4cd3
10 changed files with 195 additions and 9 deletions

View file

@ -0,0 +1,96 @@
package ru.betterend.blocks;
import java.util.Queue;
import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.FluidBlock;
import net.minecraft.block.FluidDrainable;
import net.minecraft.block.Material;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.tag.FluidTags;
import net.minecraft.util.Pair;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import ru.betterend.blocks.basis.BlockBase;
import ru.betterend.registry.EndBlocks;
public class BlockMengerSponge extends BlockBase {
public BlockMengerSponge() {
super(FabricBlockSettings.copyOf(Blocks.SPONGE));
}
@Override
public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean notify) {
if (absorbWater(world, pos)) {
world.setBlockState(pos, EndBlocks.MENGER_SPONGE_WET.getDefaultState());
}
}
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
if (absorbWater(world, pos)) {
return EndBlocks.MENGER_SPONGE_WET.getDefaultState();
}
return state;
}
private boolean absorbWater(WorldAccess world, BlockPos pos) {
Queue<Pair<BlockPos, Integer>> queue = Lists.newLinkedList();
queue.add(new Pair<BlockPos, Integer>(pos, 0));
int i = 0;
while (!queue.isEmpty()) {
Pair<BlockPos, Integer> pair = queue.poll();
BlockPos blockPos = (BlockPos) pair.getLeft();
int j = (Integer) pair.getRight();
Direction[] var8 = Direction.values();
int var9 = var8.length;
for (int var10 = 0; var10 < var9; ++var10) {
Direction direction = var8[var10];
BlockPos blockPos2 = blockPos.offset(direction);
BlockState blockState = world.getBlockState(blockPos2);
FluidState fluidState = world.getFluidState(blockPos2);
Material material = blockState.getMaterial();
if (fluidState.isIn(FluidTags.WATER)) {
if (blockState.getBlock() instanceof FluidDrainable && ((FluidDrainable) blockState.getBlock()).tryDrainFluid(world, blockPos2, blockState) != Fluids.EMPTY) {
++i;
if (j < 6) {
queue.add(new Pair<BlockPos, Integer>(blockPos2, j + 1));
}
}
else if (blockState.getBlock() instanceof FluidBlock) {
world.setBlockState(blockPos2, Blocks.AIR.getDefaultState(), 3);
++i;
if (j < 6) {
queue.add(new Pair<BlockPos, Integer>(blockPos2, j + 1));
}
}
else if (material == Material.UNDERWATER_PLANT || material == Material.REPLACEABLE_UNDERWATER_PLANT) {
BlockEntity blockEntity = blockState.getBlock().hasBlockEntity() ? world.getBlockEntity(blockPos2) : null;
dropStacks(blockState, world, blockPos2, blockEntity);
world.setBlockState(blockPos2, Blocks.AIR.getDefaultState(), 3);
++i;
if (j < 6) {
queue.add(new Pair<BlockPos, Integer>(blockPos2, j + 1));
}
}
}
}
if (i > 64) {
break;
}
}
return i > 0;
}
}

View file

@ -0,0 +1,76 @@
package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import ru.betterend.blocks.basis.BlockBase;
import ru.betterend.registry.EndBlocks;
public class BlockMengerSpongeWet extends BlockBase {
public BlockMengerSpongeWet() {
super(FabricBlockSettings.copyOf(Blocks.WET_SPONGE));
}
@Override
public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean notify) {
if (world.getDimension().isUltrawarm()) {
world.setBlockState(pos, EndBlocks.MENGER_SPONGE.getDefaultState(), 3);
world.syncWorldEvent(2009, pos, 0);
world.playSound((PlayerEntity) null, pos, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 1.0F, (1.0F + world.getRandom().nextFloat() * 0.2F) * 0.7F);
}
}
@Override
@Environment(EnvType.CLIENT)
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
Direction direction = Direction.random(random);
if (direction != Direction.UP) {
BlockPos blockPos = pos.offset(direction);
BlockState blockState = world.getBlockState(blockPos);
if (!state.isOpaque() || !blockState.isSideSolidFullSquare(world, blockPos, direction.getOpposite())) {
double x = (double) pos.getX();
double y = (double) pos.getY();
double z = (double) pos.getZ();
if (direction == Direction.DOWN) {
y -= 0.05;
x += random.nextDouble();
z += random.nextDouble();
}
else {
y += random.nextDouble() * 0.8;
if (direction.getAxis() == Direction.Axis.X) {
z += random.nextDouble();
if (direction == Direction.EAST) {
++x;
}
else {
x += 0.05;
}
}
else {
x += random.nextDouble();
if (direction == Direction.SOUTH) {
++z;
}
else {
z += 0.05;
}
}
}
world.addParticle(ParticleTypes.DRIPPING_WATER, x, y, z, 0, 0, 0);
}
}
}
}

View file

@ -35,7 +35,7 @@ import ru.betterend.world.biome.BiomeMegalake;
import ru.betterend.world.biome.BiomeMegalakeGrove; import ru.betterend.world.biome.BiomeMegalakeGrove;
import ru.betterend.world.biome.BiomePaintedMountains; import ru.betterend.world.biome.BiomePaintedMountains;
import ru.betterend.world.biome.BiomeShadowForest; import ru.betterend.world.biome.BiomeShadowForest;
import ru.betterend.world.biome.BiomeSulfurSprings; import ru.betterend.world.biome.BiomeSulphurSprings;
import ru.betterend.world.biome.EndBiome; import ru.betterend.world.biome.EndBiome;
import ru.betterend.world.generator.BiomePicker; import ru.betterend.world.generator.BiomePicker;
import ru.betterend.world.generator.BiomeType; import ru.betterend.world.generator.BiomeType;
@ -73,7 +73,7 @@ public class EndBiomes {
public static final EndBiome SHADOW_FOREST = registerBiome(new BiomeShadowForest(), BiomeType.LAND); public static final EndBiome SHADOW_FOREST = registerBiome(new BiomeShadowForest(), BiomeType.LAND);
public static final EndBiome AMBER_LAND = registerBiome(new BiomeAmberLand(), BiomeType.LAND); public static final EndBiome AMBER_LAND = registerBiome(new BiomeAmberLand(), BiomeType.LAND);
public static final EndBiome BLOSSOMING_SPIRES = registerBiome(new BiomeBlossomingSpires(), BiomeType.LAND); public static final EndBiome BLOSSOMING_SPIRES = registerBiome(new BiomeBlossomingSpires(), BiomeType.LAND);
public static final EndBiome SULFUR_SPRINGS = registerBiome(new BiomeSulfurSprings(), BiomeType.LAND); public static final EndBiome SULPHUR_SPRINGS = registerBiome(new BiomeSulphurSprings(), BiomeType.LAND);
public static void register() {} public static void register() {}

View file

@ -33,6 +33,8 @@ import ru.betterend.blocks.BlockHydraluxPetalColored;
import ru.betterend.blocks.BlockHydraluxSapling; import ru.betterend.blocks.BlockHydraluxSapling;
import ru.betterend.blocks.BlockHydrothermalVent; import ru.betterend.blocks.BlockHydrothermalVent;
import ru.betterend.blocks.BlockLacugroveSapling; import ru.betterend.blocks.BlockLacugroveSapling;
import ru.betterend.blocks.BlockMengerSponge;
import ru.betterend.blocks.BlockMengerSpongeWet;
import ru.betterend.blocks.BlockMossyGlowshroomCap; import ru.betterend.blocks.BlockMossyGlowshroomCap;
import ru.betterend.blocks.BlockMossyGlowshroomHymenophore; import ru.betterend.blocks.BlockMossyGlowshroomHymenophore;
import ru.betterend.blocks.BlockMossyGlowshroomSapling; import ru.betterend.blocks.BlockMossyGlowshroomSapling;
@ -164,6 +166,9 @@ public class EndBlocks {
public static final Block BLUE_VINE_FUR = registerBlock("blue_vine_fur", new BlockFur(BLUE_VINE_SEED, 15, 3)); public static final Block BLUE_VINE_FUR = registerBlock("blue_vine_fur", new BlockFur(BLUE_VINE_SEED, 15, 3));
public static final Block BUBBLE_CORAL = registerBlock("bubble_coral", new BlockBubbleCoral()); public static final Block BUBBLE_CORAL = registerBlock("bubble_coral", new BlockBubbleCoral());
public static final Block MENGER_SPONGE = registerBlock("menger_sponge", new BlockMengerSponge());
public static final Block MENGER_SPONGE_WET = registerBlock("menger_sponge_wet", new BlockMengerSpongeWet());
public static final Block END_LILY = registerBlockNI("end_lily", new BlockEndLily()); public static final Block END_LILY = registerBlockNI("end_lily", new BlockEndLily());
public static final Block END_LILY_SEED = registerBlock("end_lily_seed", new BlockEndLilySeed()); public static final Block END_LILY_SEED = registerBlock("end_lily_seed", new BlockEndLilySeed());

View file

@ -5,8 +5,8 @@ import ru.betterend.registry.EndFeatures;
import ru.betterend.registry.EndParticles; import ru.betterend.registry.EndParticles;
import ru.betterend.world.surface.SurfaceBuilders; import ru.betterend.world.surface.SurfaceBuilders;
public class BiomeSulfurSprings extends EndBiome { public class BiomeSulphurSprings extends EndBiome {
public BiomeSulfurSprings() { public BiomeSulphurSprings() {
super(new BiomeDefinition("sulfur_springs") super(new BiomeDefinition("sulfur_springs")
.setSurface(SurfaceBuilders.SULPHURIC_SURFACE) .setSurface(SurfaceBuilders.SULPHURIC_SURFACE)
.setWaterColor(25, 90, 157) .setWaterColor(25, 90, 157)

View file

@ -15,5 +15,6 @@
"block.betterend.sulphuric_rock_tiles": "Sulphuric Rock Tiles", "block.betterend.sulphuric_rock_tiles": "Sulphuric Rock Tiles",
"block.betterend.sulphuric_rock_wall": "Sulphuric Rock Wall", "block.betterend.sulphuric_rock_wall": "Sulphuric Rock Wall",
"block.betterend.sulphur_crystal": "Sulphur Crystal", "block.betterend.sulphur_crystal": "Sulphur Crystal",
"item.betterend.crystalline_sulphur": "Sulphur" "item.betterend.crystalline_sulphur": "Sulphur",
"biome.betterend.sulphur_springs": "Sulphur Springs",
} }

View file

@ -391,7 +391,7 @@
"block.betterend.sulphur_crystal": "Sulfur Crystal", "block.betterend.sulphur_crystal": "Sulfur Crystal",
"item.betterend.crystalline_sulphur": "Sulfur", "item.betterend.crystalline_sulphur": "Sulfur",
"biome.betterend.sulfur_springs": "Sulfur Springs", "biome.betterend.sulphur_springs": "Sulfur Springs",
"block.betterend.hydralux_petal_block": "Hydralux Petal Block", "block.betterend.hydralux_petal_block": "Hydralux Petal Block",
"block.betterend.hydralux_petal_block_black": "Black Petal Block", "block.betterend.hydralux_petal_block_black": "Black Petal Block",
"block.betterend.hydralux_petal_block_blue": "Blue Petal Block", "block.betterend.hydralux_petal_block_blue": "Blue Petal Block",
@ -411,5 +411,9 @@
"block.betterend.hydralux_petal_block_yellow": "Yellow Petal Block", "block.betterend.hydralux_petal_block_yellow": "Yellow Petal Block",
"block.betterend.hydralux_sapling": "Hydralux Sapling", "block.betterend.hydralux_sapling": "Hydralux Sapling",
"block.betterend.hydrothermal_vent": "Hydrothermal Vent", "block.betterend.hydrothermal_vent": "Hydrothermal Vent",
"item.betterend.hydralux_petal": "Hydralux Petal" "item.betterend.hydralux_petal": "Hydralux Petal",
"block.betterend.menger_sponge": "Menger Sponge",
"block.betterend.menger_sponge_wet": "Wet Menger Sponge",
"block.betterend.tube_worm": "Tube Worm"
} }

View file

@ -393,7 +393,7 @@
"block.betterend.sulphur_crystal": "Кристалл серы", "block.betterend.sulphur_crystal": "Кристалл серы",
"item.betterend.crystalline_sulphur": "Кристаллическая сера", "item.betterend.crystalline_sulphur": "Кристаллическая сера",
"biome.betterend.sulfur_springs": "Серные источники", "biome.betterend.sulphur_springs": "Серные источники",
"block.betterend.hydralux_petal_block": "Блок лепестков гидралюкса", "block.betterend.hydralux_petal_block": "Блок лепестков гидралюкса",
"block.betterend.hydralux_petal_block_black": "Чёрный блок лепестков", "block.betterend.hydralux_petal_block_black": "Чёрный блок лепестков",
"block.betterend.hydralux_petal_block_blue": "Синий блок лепестков", "block.betterend.hydralux_petal_block_blue": "Синий блок лепестков",
@ -413,5 +413,9 @@
"block.betterend.hydralux_petal_block_yellow": "Жёлтый блок лепестков", "block.betterend.hydralux_petal_block_yellow": "Жёлтый блок лепестков",
"block.betterend.hydralux_sapling": "Саженец гидралюкса", "block.betterend.hydralux_sapling": "Саженец гидралюкса",
"block.betterend.hydrothermal_vent": "Гидротермальный источник", "block.betterend.hydrothermal_vent": "Гидротермальный источник",
"item.betterend.hydralux_petal": "Лепесток гидралюкса" "item.betterend.hydralux_petal": "Лепесток гидралюкса",
"block.betterend.menger_sponge": "Губка Менгера",
"block.betterend.menger_sponge_wet": "Мокрая губка Менгера",
"block.betterend.tube_worm": "Трубчатый червь"
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB