Sulphur, brimstone

This commit is contained in:
paulevsGitch 2020-11-29 23:35:59 +03:00
parent bf7e665b36
commit 44371da207
25 changed files with 317 additions and 63 deletions

View file

@ -0,0 +1,70 @@
package ru.betterend.blocks;
import java.util.Random;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.MaterialColor;
import net.minecraft.fluid.Fluids;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import ru.betterend.blocks.basis.BlockBase;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.BlocksHelper;
public class BlockBrimstone extends BlockBase {
public static final BooleanProperty ACTIVATED = BlockProperties.ACTIVATED;
public BlockBrimstone() {
super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(MaterialColor.BROWN).ticksRandomly());
setDefaultState(stateManager.getDefaultState().with(ACTIVATED, false));
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
stateManager.add(ACTIVATED);
}
@Override
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
boolean deactivate = true;
for (Direction dir: BlocksHelper.DIRECTIONS) {
if (world.getFluidState(pos.offset(dir)).getFluid().equals(Fluids.WATER)) {
deactivate = false;
break;
}
}
if (state.get(ACTIVATED)) {
if (deactivate) {
world.setBlockState(pos, getDefaultState().with(ACTIVATED, false));
}
else if (state.get(ACTIVATED)) {
Direction dir = BlocksHelper.randomDirection(random);
BlockPos side = pos.offset(dir);
BlockState sideState = world.getBlockState(side);
if (sideState.getBlock() instanceof BlockSulphurCrystal) {
if (sideState.get(BlockSulphurCrystal.AGE) < 2) {
int age = sideState.get(BlockSulphurCrystal.AGE) + 1;
world.setBlockState(side, sideState.with(BlockSulphurCrystal.AGE, age));
}
}
else if (sideState.isAir() || !sideState.getFluidState().isEmpty()) {
boolean water = sideState.getFluidState().getFluid().equals(Fluids.WATER);
BlockState crystal = EndBlocks.SULPHUR_CRYSTAL.getDefaultState()
.with(BlockSulphurCrystal.FACING, dir)
.with(BlockSulphurCrystal.WATERLOGGED, water)
.with(BlockSulphurCrystal.AGE, 0);
world.setBlockState(side, crystal);
}
}
}
else if (!deactivate && !state.get(ACTIVATED)) {
world.setBlockState(pos, getDefaultState().with(ACTIVATED, true));
}
}
}

View file

@ -0,0 +1,86 @@
package ru.betterend.blocks;
import java.util.Collections;
import java.util.List;
import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.FluidFillable;
import net.minecraft.block.Material;
import net.minecraft.block.MaterialColor;
import net.minecraft.block.Waterloggable;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.IntProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView;
import ru.betterend.blocks.basis.BlockAttached;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
public class BlockSulphurCrystal extends BlockAttached implements IRenderTypeable, Waterloggable, FluidFillable {
public static final IntProperty AGE = IntProperty.of("age", 0, 2);
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
public BlockSulphurCrystal() {
super(FabricBlockSettings.of(Material.STONE)
.materialColor(MaterialColor.YELLOW)
.breakByTool(FabricToolTags.PICKAXES)
.sounds(BlockSoundGroup.GLASS)
.requiresTool()
.noCollision());
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
super.appendProperties(stateManager);
stateManager.add(AGE, WATERLOGGED);
}
@Override
public ERenderLayer getRenderLayer() {
return ERenderLayer.CUTOUT;
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
return state.get(AGE) < 2 ? Collections.emptyList() : Lists.newArrayList(new ItemStack(this));
}
@Override
public boolean canFillWithFluid(BlockView world, BlockPos pos, BlockState state, Fluid fluid) {
return !state.get(WATERLOGGED);
}
@Override
public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, BlockState state, FluidState fluidState) {
return !state.get(WATERLOGGED);
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
WorldView worldView = ctx.getWorld();
BlockPos blockPos = ctx.getBlockPos();
boolean water = worldView.getFluidState(blockPos).getFluid() == Fluids.WATER;
return super.getPlacementState(ctx).with(WATERLOGGED, water);
}
@Override
public FluidState getFluidState(BlockState state) {
return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : Fluids.EMPTY.getDefaultState();
}
}

View file

@ -0,0 +1,75 @@
package ru.betterend.blocks.basis;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.tag.BlockTags;
import net.minecraft.util.BlockMirror;
import net.minecraft.util.BlockRotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView;
import ru.betterend.util.BlocksHelper;
public abstract class BlockAttached extends BlockBaseNotFull {
public BlockAttached(Settings settings) {
super(settings);
}
public static final DirectionProperty FACING = Properties.FACING;
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
stateManager.add(FACING);
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
BlockState blockState = this.getDefaultState();
WorldView worldView = ctx.getWorld();
BlockPos blockPos = ctx.getBlockPos();
Direction[] directions = ctx.getPlacementDirections();
for (int i = 0; i < directions.length; ++i) {
Direction direction = directions[i];
Direction direction2 = direction.getOpposite();
blockState = (BlockState) blockState.with(FACING, direction2);
if (blockState.canPlaceAt(worldView, blockPos)) {
return blockState;
}
}
return null;
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
Direction direction = (Direction) state.get(FACING);
BlockPos blockPos = pos.offset(direction.getOpposite());
return sideCoversSmallSquare(world, blockPos, direction) || world.getBlockState(blockPos).isIn(BlockTags.LEAVES);
}
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
if (!canPlaceAt(state, world, pos)) {
return Blocks.AIR.getDefaultState();
}
else {
return state;
}
}
@Override
public BlockState rotate(BlockState state, BlockRotation rotation) {
return BlocksHelper.rotateHorizontal(state, rotation, FACING);
}
@Override
public BlockState mirror(BlockState state, BlockMirror mirror) {
return BlocksHelper.mirrorHorizontal(state, mirror, FACING);
}
}

View file

@ -8,40 +8,27 @@ import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.Material;
import net.minecraft.block.ShapeContext;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.item.ItemConvertible;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.tag.BlockTags;
import net.minecraft.util.BlockMirror;
import net.minecraft.util.BlockRotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
import ru.betterend.util.BlocksHelper;
import ru.betterend.util.MHelper;
public class BlockFur extends BlockBaseNotFull implements IRenderTypeable {
public class BlockFur extends BlockAttached implements IRenderTypeable {
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
public static final DirectionProperty FACING = Properties.FACING;
private final ItemConvertible drop;
private final int dropChance;
@ -65,51 +52,12 @@ public class BlockFur extends BlockBaseNotFull implements IRenderTypeable {
this.drop = drop;
this.dropChance = dropChance;
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
stateManager.add(FACING);
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
return BOUNDING_SHAPES.get(state.get(FACING));
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
BlockState blockState = this.getDefaultState();
WorldView worldView = ctx.getWorld();
BlockPos blockPos = ctx.getBlockPos();
Direction[] directions = ctx.getPlacementDirections();
for (int i = 0; i < directions.length; ++i) {
Direction direction = directions[i];
Direction direction2 = direction.getOpposite();
blockState = (BlockState) blockState.with(FACING, direction2);
if (blockState.canPlaceAt(worldView, blockPos)) {
return blockState;
}
}
return null;
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
Direction direction = (Direction) state.get(FACING);
BlockPos blockPos = pos.offset(direction.getOpposite());
return sideCoversSmallSquare(world, blockPos, direction) || world.getBlockState(blockPos).isIn(BlockTags.LEAVES);
}
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
if (!canPlaceAt(state, world, pos)) {
return Blocks.AIR.getDefaultState();
}
else {
return state;
}
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.get(LootContextParameters.TOOL);
@ -129,16 +77,6 @@ public class BlockFur extends BlockBaseNotFull implements IRenderTypeable {
return ERenderLayer.CUTOUT;
}
@Override
public BlockState rotate(BlockState state, BlockRotation rotation) {
return BlocksHelper.rotateHorizontal(state, rotation, FACING);
}
@Override
public BlockState mirror(BlockState state, BlockMirror mirror) {
return BlocksHelper.mirrorHorizontal(state, mirror, FACING);
}
static {
BOUNDING_SHAPES.put(Direction.UP, VoxelShapes.cuboid(0.0, 0.0, 0.0, 1.0, 0.5, 1.0));
BOUNDING_SHAPES.put(Direction.DOWN, VoxelShapes.cuboid(0.0, 0.5, 0.0, 1.0, 1.0, 1.0));

View file

@ -14,6 +14,7 @@ import ru.betterend.blocks.BlockAmber;
import ru.betterend.blocks.BlockBlueVine;
import ru.betterend.blocks.BlockBlueVineLantern;
import ru.betterend.blocks.BlockBlueVineSeed;
import ru.betterend.blocks.BlockBrimstone;
import ru.betterend.blocks.BlockBubbleCoral;
import ru.betterend.blocks.BlockBulbVine;
import ru.betterend.blocks.BlockBulbVineSeed;
@ -37,6 +38,7 @@ import ru.betterend.blocks.BlockPath;
import ru.betterend.blocks.BlockPythadendronSapling;
import ru.betterend.blocks.BlockShadowBerry;
import ru.betterend.blocks.BlockShadowGrass;
import ru.betterend.blocks.BlockSulphurCrystal;
import ru.betterend.blocks.BlockTenaneaFlowers;
import ru.betterend.blocks.BlockTenaneaSapling;
import ru.betterend.blocks.BlockTerrain;
@ -96,8 +98,13 @@ public class EndBlocks {
// Rocks //
public static final StoneMaterial FLAVOLITE = new StoneMaterial("flavolite", MaterialColor.SAND);
public static final StoneMaterial VIOLECITE = new StoneMaterial("violecite", MaterialColor.PURPLE);
public static final StoneMaterial SULFURIC_ROCK = new StoneMaterial("sulfuric_rock", MaterialColor.BROWN);
public static final Block BRIMSTONE = registerBlock("brimstone", new BlockBrimstone());
public static final Block SULPHUR_CRYSTAL = registerBlock("sulphur_crystal", new BlockSulphurCrystal());
public static final Block FLAVOLITE_RUNED = registerBlock("flavolite_runed", new RunedFlavolite());
public static final Block FLAVOLITE_RUNED_ETERNAL = registerBlock("flavolite_runed_eternal", new EternalRunedFlavolite());
public static final Block ANDESITE_PEDESTAL = registerBlock("andesite_pedestal", new PedestalVanilla(Blocks.ANDESITE));
public static final Block DIORITE_PEDESTAL = registerBlock("diorite_pedestal", new PedestalVanilla(Blocks.DIORITE));
public static final Block GRANITE_PEDESTAL = registerBlock("granite_pedestal", new PedestalVanilla(Blocks.GRANITE));

View file

@ -59,6 +59,7 @@ public class EndItems {
public final static Item RAW_AMBER = registerItem("raw_amber");
public final static Item AMBER_GEM = registerItem("amber_gem");
public final static Item GLOWING_BULB = registerItem("glowing_bulb");
public final static Item CRYSTALLINE_SULFUR = registerItem("crystalline_sulfur");
// Armor //
public static final Item TERMINITE_HELMET = registerItem("terminite_helmet", new ArmorItem(EndArmorMaterial.TERMINITE, EquipmentSlot.HEAD, makeSettings()));

View file

@ -293,4 +293,8 @@ public class BlocksHelper {
public static Direction randomHorizontal(Random random) {
return HORIZONTAL[random.nextInt(4)];
}
public static Direction randomDirection(Random random) {
return DIRECTIONS[random.nextInt(6)];
}
}

View file

@ -0,0 +1,6 @@
{
"variants": {
"active=true": { "model": "betterend:block/brimstone_active" },
"active=false": { "model": "betterend:block/brimstone_normal" }
}
}

View file

@ -0,0 +1,22 @@
{
"variants": {
"age=0,facing=up": { "model": "betterend:block/sulphur_crystal_0" },
"age=0,facing=down": { "model": "betterend:block/sulphur_crystal_0", "x": 180 },
"age=0,facing=north": { "model": "betterend:block/sulphur_crystal_0", "x": 90 },
"age=0,facing=south": { "model": "betterend:block/sulphur_crystal_0", "x": 90, "y": 180 },
"age=0,facing=east": { "model": "betterend:block/sulphur_crystal_0", "x": 90, "y": 90 },
"age=0,facing=west": { "model": "betterend:block/sulphur_crystal_0", "x": 90, "y": 270 },
"age=1,facing=up": { "model": "betterend:block/sulphur_crystal_1" },
"age=1,facing=down": { "model": "betterend:block/sulphur_crystal_1", "x": 180 },
"age=1,facing=north": { "model": "betterend:block/sulphur_crystal_1", "x": 90 },
"age=1,facing=south": { "model": "betterend:block/sulphur_crystal_1", "x": 90, "y": 180 },
"age=1,facing=east": { "model": "betterend:block/sulphur_crystal_1", "x": 90, "y": 90 },
"age=1,facing=west": { "model": "betterend:block/sulphur_crystal_1", "x": 90, "y": 270 },
"age=2,facing=up": { "model": "betterend:block/sulphur_crystal_2" },
"age=2,facing=down": { "model": "betterend:block/sulphur_crystal_2", "x": 180 },
"age=2,facing=north": { "model": "betterend:block/sulphur_crystal_2", "x": 90 },
"age=2,facing=south": { "model": "betterend:block/sulphur_crystal_2", "x": 90, "y": 180 },
"age=2,facing=east": { "model": "betterend:block/sulphur_crystal_2", "x": 90, "y": 90 },
"age=2,facing=west": { "model": "betterend:block/sulphur_crystal_2", "x": 90, "y": 270 }
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "betterend:block/brimstone"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "betterend:block/inactive_brimstone"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cross",
"textures": {
"cross": "betterend:block/sulphur_crystal_0"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cross",
"textures": {
"cross": "betterend:block/sulphur_crystal_1"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "block/cross",
"textures": {
"cross": "betterend:block/sulphur_crystal_2"
}
}

View file

@ -0,0 +1,3 @@
{
"parent": "betterend:block/brimstone_normal"
}

View file

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "betterend:block/crystalline_sulfur"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "betterend:block/crystalline_sulfur_3"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 312 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 442 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 419 B