Lantern fixes & improvements

This commit is contained in:
paulevsGitch 2020-11-27 11:30:00 +03:00
parent 29f84ef7e7
commit 6953437705
14 changed files with 319 additions and 167 deletions

View file

@ -1,91 +0,0 @@
package ru.betterend.blocks;
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.MaterialColor;
import net.minecraft.block.ShapeContext;
import net.minecraft.block.Waterloggable;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView;
import ru.betterend.blocks.basis.BlockBaseNotFull;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
public class BlockBulbVineLantern extends BlockBaseNotFull implements IRenderTypeable, Waterloggable {
private static final VoxelShape SHAPE_CEIL = Block.createCuboidShape(4, 4, 4, 12, 16, 12);
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
public BlockBulbVineLantern() {
this(FabricBlockSettings.of(Material.METAL)
.sounds(BlockSoundGroup.LANTERN)
.hardness(1)
.resistance(1)
.breakByTool(FabricToolTags.PICKAXES)
.materialColor(MaterialColor.LIGHT_GRAY)
.requiresTool()
.luminance(15));
}
public BlockBulbVineLantern(FabricBlockSettings settings) {
super(settings);
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
stateManager.add(WATERLOGGED);
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
WorldView worldView = ctx.getWorld();
BlockPos blockPos = ctx.getBlockPos();
if (sideCoversSmallSquare(worldView, blockPos.up(), Direction.DOWN)) {
boolean water = worldView.getFluidState(blockPos).getFluid() == Fluids.WATER;
return getDefaultState().with(WATERLOGGED, water);
}
return null;
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
return sideCoversSmallSquare(world, pos.up(), Direction.DOWN);
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
return SHAPE_CEIL;
}
@Override
public ERenderLayer getRenderLayer() {
return ERenderLayer.CUTOUT;
}
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
Boolean water = state.get(WATERLOGGED);
if (water) {
world.getFluidTickScheduler().schedule(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
}
if (!canPlaceAt(state, world, pos)) {
return water ? Blocks.WATER.getDefaultState() : Blocks.AIR.getDefaultState();
}
else {
return state;
}
}
}

View file

@ -0,0 +1,45 @@
package ru.betterend.blocks.basis;
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.Material;
import net.minecraft.block.MaterialColor;
import net.minecraft.block.ShapeContext;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
public class BlockBulbVineLantern extends BlockLantern implements IRenderTypeable {
private static final VoxelShape SHAPE_CEIL = Block.createCuboidShape(4, 4, 4, 12, 16, 12);
private static final VoxelShape SHAPE_FLOOR = Block.createCuboidShape(4, 0, 4, 12, 12, 12);
public BlockBulbVineLantern() {
this(FabricBlockSettings.of(Material.METAL)
.sounds(BlockSoundGroup.LANTERN)
.hardness(1)
.resistance(1)
.breakByTool(FabricToolTags.PICKAXES)
.materialColor(MaterialColor.LIGHT_GRAY)
.requiresTool()
.luminance(15));
}
public BlockBulbVineLantern(FabricBlockSettings settings) {
super(settings);
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
return state.get(IS_FLOOR) ? SHAPE_FLOOR : SHAPE_CEIL;
}
@Override
public ERenderLayer getRenderLayer() {
return ERenderLayer.CUTOUT;
}
}

View file

@ -1,4 +1,4 @@
package ru.betterend.blocks;
package ru.betterend.blocks.basis;
import java.io.Reader;
@ -44,11 +44,17 @@ public class BlockBulbVineLanternColored extends BlockBulbVineLantern implements
@Override
public String getModelPattern(String block) {
return Patterns.createJson(Patterns.BLOCK_BULB_LANTERN_COLORED, "", "");
String path = "betterend:block/bulb_lantern_colored";
if (block.contains("item") || block.contains("ceil")) {
return Patterns.createJson(Patterns.BLOCK_BULB_LANTERN_COLORED_CEIL, path, path);
}
else {
return Patterns.createJson(Patterns.BLOCK_BULB_LANTERN_COLORED_FLOOR, path, path);
}
}
@Override
public Identifier statePatternId() {
return Patterns.STATE_DIRECT;
return Patterns.STATE_BULB_LANTERN;
}
}

View file

@ -0,0 +1,118 @@
package ru.betterend.blocks.basis;
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.FluidFillable;
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.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView;
public class BlockLantern extends BlockBaseNotFull implements Waterloggable, FluidFillable {
public static final BooleanProperty IS_FLOOR = BooleanProperty.of("is_floor");
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
public BlockLantern(Block source) {
this(FabricBlockSettings.copyOf(source).luminance(15));
}
public BlockLantern(FabricBlockSettings settings) {
super(settings);
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
stateManager.add(IS_FLOOR, WATERLOGGED);
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
WorldView worldView = ctx.getWorld();
BlockPos blockPos = ctx.getBlockPos();
Direction dir = ctx.getSide();
boolean water = worldView.getFluidState(blockPos).getFluid() == Fluids.WATER;
if (dir != Direction.DOWN && dir != Direction.UP) {
if (sideCoversSmallSquare(worldView, blockPos.up(), Direction.DOWN)) {
return getDefaultState().with(IS_FLOOR, false).with(WATERLOGGED, water);
}
else if (sideCoversSmallSquare(worldView, blockPos.down(), Direction.UP)) {
return getDefaultState().with(IS_FLOOR, true).with(WATERLOGGED, water);
}
else {
return null;
}
}
else if (dir == Direction.DOWN) {
if (sideCoversSmallSquare(worldView, blockPos.up(), Direction.DOWN)) {
return getDefaultState().with(IS_FLOOR, false).with(WATERLOGGED, water);
}
else if (sideCoversSmallSquare(worldView, blockPos.down(), Direction.UP)) {
return getDefaultState().with(IS_FLOOR, true).with(WATERLOGGED, water);
}
else {
return null;
}
}
else {
if (sideCoversSmallSquare(worldView, blockPos.down(), Direction.UP)) {
return getDefaultState().with(IS_FLOOR, true).with(WATERLOGGED, water);
}
else if (sideCoversSmallSquare(worldView, blockPos.up(), Direction.DOWN)) {
return getDefaultState().with(IS_FLOOR, false).with(WATERLOGGED, water);
}
else {
return null;
}
}
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
if (state.get(IS_FLOOR)) {
return sideCoversSmallSquare(world, pos.down(), Direction.UP);
}
else {
return sideCoversSmallSquare(world, pos.up(), Direction.DOWN);
}
}
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
Boolean water = state.get(WATERLOGGED);
if (water) {
world.getFluidTickScheduler().schedule(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
}
if (!canPlaceAt(state, world, pos)) {
return water ? Blocks.WATER.getDefaultState() : Blocks.AIR.getDefaultState();
}
else {
return state;
}
}
@Override
public boolean canFillWithFluid(BlockView world, BlockPos pos, BlockState state, Fluid fluid) {
return false;
}
@Override
public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, BlockState state, FluidState fluidState) {
return false;
}
@Override
public FluidState getFluidState(BlockState state) {
return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : Fluids.EMPTY.getDefaultState();
}
}

View file

@ -5,35 +5,22 @@ import java.io.Reader;
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.ShapeContext;
import net.minecraft.block.Waterloggable;
import net.minecraft.client.color.block.BlockColorProvider;
import net.minecraft.client.color.item.ItemColorProvider;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3i;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView;
import ru.betterend.blocks.AuroraCrystalBlock;
import ru.betterend.interfaces.IColorProvider;
import ru.betterend.patterns.Patterns;
import ru.betterend.util.MHelper;
public class BlockStoneLantern extends BlockBaseNotFull implements IColorProvider, Waterloggable {
public static final BooleanProperty IS_FLOOR = BooleanProperty.of("is_floor");
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
public class BlockStoneLantern extends BlockLantern implements IColorProvider {
private static final VoxelShape SHAPE_CEIL = Block.createCuboidShape(3, 1, 3, 13, 16, 13);
private static final VoxelShape SHAPE_FLOOR = Block.createCuboidShape(3, 0, 3, 13, 15, 13);
private static final Vec3i[] COLORS = AuroraCrystalBlock.COLORS;
@ -42,31 +29,6 @@ public class BlockStoneLantern extends BlockBaseNotFull implements IColorProvide
super(FabricBlockSettings.copyOf(source).luminance(15));
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
stateManager.add(IS_FLOOR, WATERLOGGED);
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
WorldView worldView = ctx.getWorld();
BlockPos blockPos = ctx.getBlockPos();
Direction dir = ctx.getSide();
if (dir == Direction.DOWN) {
if (sideCoversSmallSquare(worldView, blockPos.up(), Direction.DOWN)) {
boolean water = worldView.getFluidState(blockPos).getFluid() == Fluids.WATER;
return getDefaultState().with(IS_FLOOR, false).with(WATERLOGGED, water);
}
}
else {
if (sideCoversSmallSquare(worldView, blockPos.down(), Direction.UP)) {
boolean water = worldView.getFluidState(blockPos).getFluid() == Fluids.WATER;
return getDefaultState().with(IS_FLOOR, true).with(WATERLOGGED, water);
}
}
return null;
}
@Override
public BlockColorProvider getProvider() {
return (state, world, pos, tintIndex) -> {
@ -100,30 +62,6 @@ public class BlockStoneLantern extends BlockBaseNotFull implements IColorProvide
return state.get(IS_FLOOR) ? SHAPE_FLOOR : SHAPE_CEIL;
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
if (state.get(IS_FLOOR)) {
return sideCoversSmallSquare(world, pos.down(), Direction.UP);
}
else {
return sideCoversSmallSquare(world, pos.up(), Direction.DOWN);
}
}
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
Boolean water = state.get(WATERLOGGED);
if (water) {
world.getFluidTickScheduler().schedule(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
}
if (!canPlaceAt(state, world, pos)) {
return water ? Blocks.WATER.getDefaultState() : Blocks.AIR.getDefaultState();
}
else {
return state;
}
}
@Override
public Identifier statePatternId() {
return Patterns.STATE_STONE_LANTERN;

View file

@ -34,6 +34,7 @@ public class Patterns {
public final static Identifier STATE_PEDESTAL = BetterEnd.makeID("patterns/blockstate/pattern_pedestal.json");
public final static Identifier STATE_STONE_LANTERN = BetterEnd.makeID("patterns/blockstate/stone_lantern.json");
public final static Identifier STATE_DIRECT = BetterEnd.makeID("patterns/blockstate/pattern_direct.json");
public final static Identifier STATE_BULB_LANTERN = BetterEnd.makeID("patterns/blockstate/bulb_lantern.json");
//Models Block
public final static Identifier BLOCK_EMPTY = BetterEnd.makeID("patterns/block/pattern_empty.json");
@ -75,7 +76,8 @@ public class Patterns {
public final static Identifier BLOCK_BOOKSHELF = BetterEnd.makeID("patterns/block/bookshelf.json");
public final static Identifier BLOCK_STONE_LANTERN_CEIL = BetterEnd.makeID("patterns/block/stone_lantern_ceil.json");
public final static Identifier BLOCK_STONE_LANTERN_FLOOR = BetterEnd.makeID("patterns/block/stone_lantern_floor.json");
public final static Identifier BLOCK_BULB_LANTERN_COLORED = BetterEnd.makeID("models/block/bulb_lantern_colored.json");
public final static Identifier BLOCK_BULB_LANTERN_COLORED_FLOOR = BetterEnd.makeID("models/block/bulb_lantern_colored_floor.json");
public final static Identifier BLOCK_BULB_LANTERN_COLORED_CEIL = BetterEnd.makeID("models/block/bulb_lantern_colored_ceil.json");
//Models Item
public final static Identifier ITEM_WALL = BetterEnd.makeID("patterns/item/pattern_wall.json");

View file

@ -16,8 +16,6 @@ import ru.betterend.blocks.BlockBlueVineLantern;
import ru.betterend.blocks.BlockBlueVineSeed;
import ru.betterend.blocks.BlockBubbleCoral;
import ru.betterend.blocks.BlockBulbVine;
import ru.betterend.blocks.BlockBulbVineLantern;
import ru.betterend.blocks.BlockBulbVineLanternColored;
import ru.betterend.blocks.BlockBulbVineSeed;
import ru.betterend.blocks.BlockChorusGrass;
import ru.betterend.blocks.BlockDragonTreeSapling;
@ -54,6 +52,8 @@ import ru.betterend.blocks.InfusionPedestal;
import ru.betterend.blocks.PedestalVanilla;
import ru.betterend.blocks.RunedFlavolite;
import ru.betterend.blocks.TerminiteBlock;
import ru.betterend.blocks.basis.BlockBulbVineLantern;
import ru.betterend.blocks.basis.BlockBulbVineLanternColored;
import ru.betterend.blocks.basis.BlockFur;
import ru.betterend.blocks.basis.BlockLeaves;
import ru.betterend.blocks.basis.BlockOre;

View file

@ -1,7 +1,6 @@
{
"variants": {
"": [
{ "model": "betterend:block/bulb_vine_lantern" }
]
}
}
"variants": {
"is_floor=false": { "model": "betterend:block/bulb_vine_lantern_ceil" },
"is_floor=true": { "model": "betterend:block/bulb_vine_lantern_floor" }
}
}

View file

@ -0,0 +1,73 @@
{
"__comment": "Designed by Paulevs with Cubik Studio - https://cubik.studio",
"parent": "block/block",
"textures": {
"overlay": "betterend:block/bulb_vine_lantern_overlay",
"metal": "betterend:block/bulb_vine_lantern_metal",
"particle": "#overlay"
},
"elements": [
{
"__comment": "Box1",
"from": [ 4, 0, 4 ],
"to": [ 12, 8, 12 ],
"shade": false,
"faces": {
"down": { "uv": [ 8, 0, 16, 8 ], "texture": "#metal" },
"up": { "uv": [ 0, 0, 8, 8 ], "texture": "#metal" },
"north": { "uv": [ 0, 8, 8, 16 ], "texture": "#metal" },
"south": { "uv": [ 0, 8, 8, 16 ], "texture": "#metal" },
"west": { "uv": [ 0, 8, 8, 16 ], "texture": "#metal" },
"east": { "uv": [ 0, 8, 8, 16 ], "texture": "#metal" }
}
},
{
"__comment": "Box1",
"from": [ 4, 0, 4 ],
"to": [ 12, 8, 12 ],
"shade": false,
"faces": {
"down": { "uv": [ 8, 0, 16, 8 ], "texture": "#overlay", "tintindex": 0 },
"up": { "uv": [ 0, 0, 8, 8 ], "texture": "#overlay", "tintindex": 0 },
"north": { "uv": [ 0, 8, 8, 16 ], "texture": "#overlay", "tintindex": 0 },
"south": { "uv": [ 0, 8, 8, 16 ], "texture": "#overlay", "tintindex": 0 },
"west": { "uv": [ 0, 8, 8, 16 ], "texture": "#overlay", "tintindex": 0 },
"east": { "uv": [ 0, 8, 8, 16 ], "texture": "#overlay", "tintindex": 0 }
}
},
{
"__comment": "Box11",
"from": [ 6, 8, 6 ],
"to": [ 10, 9, 10 ],
"faces": {
"up": { "uv": [ 10, 8, 14, 12 ], "texture": "#metal" },
"north": { "uv": [ 10, 12, 14, 13 ], "texture": "#metal" },
"south": { "uv": [ 10, 12, 14, 13 ], "texture": "#metal" },
"west": { "uv": [ 10, 12, 14, 13 ], "texture": "#metal" },
"east": { "uv": [ 10, 12, 14, 13 ], "texture": "#metal" }
}
},
{
"__comment": "PlaneX15",
"from": [ 7, 9, 7 ],
"to": [ 7.001, 12, 10 ],
"rotation": { "origin": [ 7, 13, 7 ], "axis": "y", "angle": 45 },
"shade": false,
"faces": {
"west": { "uv": [ 10, 13, 13, 16 ], "texture": "#metal" },
"east": { "uv": [ 10, 13, 13, 16 ], "texture": "#metal" }
}
},
{
"__comment": "PlaneX15",
"from": [ 9, 9, 7 ],
"to": [ 9.001, 12, 10 ],
"rotation": { "origin": [ 9, 13, 7 ], "axis": "y", "angle": -45 },
"shade": false,
"faces": {
"west": { "uv": [ 10, 13, 13, 16 ], "texture": "#metal" },
"east": { "uv": [ 10, 13, 13, 16 ], "texture": "#metal" }
}
}
]
}

View file

@ -0,0 +1,56 @@
{
"__comment": "Designed by Paulevs with Cubik Studio - https://cubik.studio",
"parent": "block/block",
"textures": {
"particle": "betterend:block/bulb_vine_lantern",
"texture": "betterend:block/bulb_vine_lantern"
},
"elements": [
{
"from": [ 4, 0, 4 ],
"to": [ 12, 8, 12 ],
"shade": false,
"faces": {
"down": { "uv": [ 8, 0, 16, 8 ], "texture": "#texture" },
"up": { "uv": [ 0, 0, 8, 8 ], "texture": "#texture" },
"north": { "uv": [ 0, 8, 8, 16 ], "texture": "#texture" },
"south": { "uv": [ 0, 8, 8, 16 ], "texture": "#texture" },
"west": { "uv": [ 0, 8, 8, 16 ], "texture": "#texture" },
"east": { "uv": [ 0, 8, 8, 16 ], "texture": "#texture" }
}
},
{
"from": [ 6, 8, 6 ],
"to": [ 10, 9, 10 ],
"faces": {
"up": { "uv": [ 10, 8, 14, 12 ], "texture": "#texture" },
"north": { "uv": [ 10, 12, 14, 13 ], "texture": "#texture" },
"south": { "uv": [ 10, 12, 14, 13 ], "texture": "#texture" },
"west": { "uv": [ 10, 12, 14, 13 ], "texture": "#texture" },
"east": { "uv": [ 10, 12, 14, 13 ], "texture": "#texture" }
}
},
{
"__comment": "PlaneX15",
"from": [ 7, 9, 7 ],
"to": [ 7.001, 12, 10 ],
"rotation": { "origin": [ 7, 13, 7 ], "axis": "y", "angle": 45 },
"shade": false,
"faces": {
"west": { "uv": [ 10, 13, 13, 16 ], "texture": "#texture" },
"east": { "uv": [ 10, 13, 13, 16 ], "texture": "#texture" }
}
},
{
"__comment": "PlaneX15",
"from": [ 9, 9, 7 ],
"to": [ 9.001, 12, 10 ],
"rotation": { "origin": [ 9, 13, 7 ], "axis": "y", "angle": -45 },
"shade": false,
"faces": {
"west": { "uv": [ 10, 13, 13, 16 ], "texture": "#texture" },
"east": { "uv": [ 10, 13, 13, 16 ], "texture": "#texture" }
}
}
]
}

View file

@ -1,3 +1,3 @@
{
"parent": "betterend:block/bulb_vine_lantern"
"parent": "betterend:block/bulb_vine_lantern_ceil"
}

View file

@ -0,0 +1,6 @@
{
"variants": {
"is_floor=false": { "model": "%block%_ceil" },
"is_floor=true": { "model": "%block%_floor" }
}
}