Teneanea improvements and leaves

This commit is contained in:
paulevsGitch 2020-11-26 15:16:53 +03:00
parent e3d5065e12
commit 5ee7a94ef6
28 changed files with 469 additions and 54 deletions

View file

@ -29,6 +29,8 @@ public class AuroraCrystalBlock extends AbstractGlassBlock implements IRenderTyp
public static final Vec3i[] COLORS;
private static final int MIN_DROP = 1;
private static final int MAX_DROP = 4;
private static final BlockColorProvider BLOCK_PROVIDER;
private static final ItemColorProvider ITEM_PROVIDER;
public AuroraCrystalBlock() {
super(FabricBlockSettings.of(Material.GLASS)
@ -43,30 +45,12 @@ public class AuroraCrystalBlock extends AbstractGlassBlock implements IRenderTyp
@Override
public BlockColorProvider getProvider() {
return (state, world, pos, tintIndex) -> {
long i = (long) pos.getX() + (long) pos.getY() + (long) pos.getZ();
double delta = i * 0.1;
int index = MHelper.floor(delta);
int index2 = (index + 1) & 3;
delta -= index;
index &= 3;
Vec3i color1 = COLORS[index];
Vec3i color2 = COLORS[index2];
int r = MHelper.floor(MathHelper.lerp(delta, color1.getX(), color2.getX()));
int g = MHelper.floor(MathHelper.lerp(delta, color1.getY(), color2.getY()));
int b = MHelper.floor(MathHelper.lerp(delta, color1.getZ(), color2.getZ()));
return MHelper.color(r, g, b);
};
return BLOCK_PROVIDER;
}
@Override
public ItemColorProvider getItemProvider() {
return (stack, tintIndex) -> {
return MHelper.color(COLORS[3].getX(), COLORS[3].getY(), COLORS[3].getZ());
};
return ITEM_PROVIDER;
}
@Override
@ -106,5 +90,27 @@ public class AuroraCrystalBlock extends AbstractGlassBlock implements IRenderTyp
new Vec3i(120, 255, 168),
new Vec3i(243, 58, 255)
};
BLOCK_PROVIDER = (state, world, pos, tintIndex) -> {
long i = (long) pos.getX() + (long) pos.getY() + (long) pos.getZ();
double delta = i * 0.1;
int index = MHelper.floor(delta);
int index2 = (index + 1) & 3;
delta -= index;
index &= 3;
Vec3i color1 = COLORS[index];
Vec3i color2 = COLORS[index2];
int r = MHelper.floor(MathHelper.lerp(delta, color1.getX(), color2.getX()));
int g = MHelper.floor(MathHelper.lerp(delta, color1.getY(), color2.getY()));
int b = MHelper.floor(MathHelper.lerp(delta, color1.getZ(), color2.getZ()));
return MHelper.color(r, g, b);
};
ITEM_PROVIDER = (stack, tintIndex) -> {
return MHelper.color(COLORS[3].getX(), COLORS[3].getY(), COLORS[3].getZ());
};
}
}

View file

@ -7,7 +7,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.StructureWorldAccess;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.BlockGlowingFur;
import ru.betterend.blocks.basis.BlockFur;
import ru.betterend.blocks.basis.BlockPlantWithAge;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.BlocksHelper;
@ -34,11 +34,11 @@ public class BlockBlueVineSeed extends BlockPlantWithAge {
for (Direction dir: BlocksHelper.HORIZONTAL) {
BlockPos p = pos.offset(dir);
if (world.isAir(p)) {
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.BLUE_VINE_FUR.getDefaultState().with(BlockGlowingFur.FACING, dir));
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.BLUE_VINE_FUR.getDefaultState().with(BlockFur.FACING, dir));
}
}
if (world.isAir(pos.up())) {
BlocksHelper.setWithoutUpdate(world, pos.up(), EndBlocks.BLUE_VINE_FUR.getDefaultState().with(BlockGlowingFur.FACING, Direction.UP));
BlocksHelper.setWithoutUpdate(world, pos.up(), EndBlocks.BLUE_VINE_FUR.getDefaultState().with(BlockFur.FACING, Direction.UP));
}
}

View file

@ -0,0 +1,60 @@
package ru.betterend.blocks;
import net.minecraft.client.color.block.BlockColorProvider;
import net.minecraft.client.color.item.ItemColorProvider;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3i;
import ru.betterend.blocks.basis.BlockVine;
import ru.betterend.interfaces.IColorProvider;
import ru.betterend.util.MHelper;
public class BlockTenaneaFlowers extends BlockVine implements IColorProvider {
private static final BlockColorProvider BLOCK_PROVIDER;
private static final ItemColorProvider ITEM_PROVIDER;
public static final Vec3i[] COLORS;
public BlockTenaneaFlowers() {
super(15);
}
@Override
public BlockColorProvider getProvider() {
return BLOCK_PROVIDER;
}
@Override
public ItemColorProvider getItemProvider() {
return ITEM_PROVIDER;
}
static {
COLORS = new Vec3i[] {
new Vec3i(250, 111, 222),
new Vec3i(167, 89, 255),
new Vec3i(120, 207, 239),
new Vec3i(255, 87, 182)
};
BLOCK_PROVIDER = (state, world, pos, tintIndex) -> {
long i = (MHelper.getRandom(pos.getX(), pos.getZ()) & 63) + pos.getY();
double delta = i * 0.1;
int index = MHelper.floor(delta);
int index2 = (index + 1) & 3;
delta -= index;
index &= 3;
Vec3i color1 = COLORS[index];
Vec3i color2 = COLORS[index2];
int r = MHelper.floor(MathHelper.lerp(delta, color1.getX(), color2.getX()));
int g = MHelper.floor(MathHelper.lerp(delta, color1.getY(), color2.getY()));
int b = MHelper.floor(MathHelper.lerp(delta, color1.getZ(), color2.getZ()));
return MHelper.color(r, g, b);
};
ITEM_PROVIDER = (stack, tintIndex) -> {
return MHelper.color(COLORS[0].getX(), COLORS[0].getY(), COLORS[0].getZ());
};
}
}

View file

@ -24,6 +24,7 @@ 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;
@ -38,13 +39,24 @@ import ru.betterend.interfaces.IRenderTypeable;
import ru.betterend.util.BlocksHelper;
import ru.betterend.util.MHelper;
public class BlockGlowingFur extends BlockBaseNotFull implements IRenderTypeable {
public class BlockFur extends BlockBaseNotFull 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;
public BlockGlowingFur(ItemConvertible drop, int dropChance) {
public BlockFur(ItemConvertible drop, int light, int dropChance) {
super(FabricBlockSettings.of(Material.REPLACEABLE_PLANT)
.breakByTool(FabricToolTags.SHEARS)
.sounds(BlockSoundGroup.WET_GRASS)
.luminance(light)
.breakByHand(true)
.noCollision());
this.drop = drop;
this.dropChance = dropChance;
}
public BlockFur(ItemConvertible drop, int dropChance) {
super(FabricBlockSettings.of(Material.REPLACEABLE_PLANT)
.breakByTool(FabricToolTags.SHEARS)
.sounds(BlockSoundGroup.WET_GRASS)
@ -86,7 +98,7 @@ public class BlockGlowingFur extends BlockBaseNotFull implements IRenderTypeable
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);
return sideCoversSmallSquare(world, blockPos, direction) || world.getBlockState(pos).isIn(BlockTags.LEAVES);
}
@Override

View file

@ -11,6 +11,9 @@ import net.minecraft.block.Material;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.WorldView;
public class BlockWallMushroom extends BlockWallPlant {
public BlockWallMushroom(int light) {
@ -28,4 +31,9 @@ public class BlockWallMushroom extends BlockWallPlant {
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
return Lists.newArrayList(new ItemStack(this));
}
@Override
public boolean isSupport(WorldView world, BlockPos pos, BlockState blockState, Direction direction) {
return blockState.getMaterial().isSolid() && blockState.isSideSolidFullSquare(world, pos, direction);
}
}