Chandeliers

This commit is contained in:
paulevsGitch 2021-01-25 07:31:55 +03:00
parent 1985750261
commit 5da6976158
34 changed files with 515 additions and 24 deletions

View file

@ -1,5 +1,6 @@
package ru.betterend.blocks;
import java.io.Reader;
import java.util.EnumMap;
import com.google.common.collect.Maps;
@ -8,20 +9,24 @@ import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.ShapeContext;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import ru.betterend.blocks.basis.AttachedBlock;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class ChandelierBlock extends AttachedBlock implements IRenderTypeable {
public class ChandelierBlock extends AttachedBlock implements IRenderTypeable, BlockPatterned {
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
public ChandelierBlock(FabricBlockSettings settings) {
super(settings.noCollision().nonOpaque().requiresTool().luminance(15));
public ChandelierBlock(Block source) {
super(FabricBlockSettings.copyOf(source).noCollision().nonOpaque().requiresTool().luminance(15));
}
@Override
@ -34,6 +39,34 @@ public class ChandelierBlock extends AttachedBlock implements IRenderTypeable {
return BOUNDING_SHAPES.get(state.get(FACING));
}
@Override
public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this);
return Patterns.createJson(data, blockId.getPath(), blockId.getPath());
}
@Override
public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this);
if (block.contains("item")) {
return Patterns.createJson(Patterns.ITEM_GENERATED, "item/" + blockId.getPath());
}
else if (block.contains("ceil")) {
return Patterns.createJson(Patterns.BLOCK_CHANDELIER_CEIL, blockId.getPath());
}
else if (block.contains("wall")) {
return Patterns.createJson(Patterns.BLOCK_CHANDELIER_WALL, blockId.getPath());
}
else {
return Patterns.createJson(Patterns.BLOCK_CHANDELIER_FLOOR, blockId.getPath());
}
}
@Override
public Identifier statePatternId() {
return Patterns.STATE_CHANDELIER;
}
static {
BOUNDING_SHAPES.put(Direction.UP, Block.createCuboidShape(5, 0, 5, 11, 13, 11));
BOUNDING_SHAPES.put(Direction.DOWN, Block.createCuboidShape(5, 3, 5, 11, 16, 11));

View file

@ -74,7 +74,7 @@ public class MetalMaterial {
chain = EndBlocks.registerBlock(name + "_chain", new EndChainBlock(color));
plate = EndBlocks.registerBlock(name + "_plate", new EndWoodenPlateBlock(block));
chandelier = EndBlocks.registerBlock(name + "_chandelier", new ChandelierBlock(materialBlock));
chandelier = EndBlocks.registerBlock(name + "_chandelier", new ChandelierBlock(block));
bulb_lantern = EndBlocks.registerBlock(name + "_bulb_lantern", new BulbVineLanternBlock(lantern));
bulb_lantern_colored = new ColoredMaterial(BulbVineLanternColoredBlock::new, bulb_lantern, false);

View file

@ -41,6 +41,7 @@ public class Patterns {
public final static Identifier STATE_BARS = BetterEnd.makeID("patterns/blockstate/bars.json");
public final static Identifier STATE_ANVIL = BetterEnd.makeID("patterns/blockstate/anvil.json");
public final static Identifier STATE_CHAIN = BetterEnd.makeID("patterns/blockstate/chain.json");
public final static Identifier STATE_CHANDELIER = BetterEnd.makeID("patterns/blockstate/chandelier.json");
//Models Block
public final static Identifier BLOCK_EMPTY = BetterEnd.makeID("patterns/block/empty.json");
@ -91,6 +92,9 @@ public class Patterns {
public final static Identifier BLOCK_BARS_SIDE = BetterEnd.makeID("patterns/block/bars_side.json");
public final static Identifier BLOCK_ANVIL = BetterEnd.makeID("patterns/block/anvil.json");
public final static Identifier BLOCK_CHAIN = BetterEnd.makeID("patterns/block/chain.json");
public final static Identifier BLOCK_CHANDELIER_FLOOR = BetterEnd.makeID("patterns/block/chandelier_floor.json");
public final static Identifier BLOCK_CHANDELIER_WALL = BetterEnd.makeID("patterns/block/chandelier_wall.json");
public final static Identifier BLOCK_CHANDELIER_CEIL = BetterEnd.makeID("patterns/block/chandelier_ceil.json");
//Models Item
public final static Identifier ITEM_WALL = BetterEnd.makeID("patterns/item/pattern_wall.json");

View file

@ -196,6 +196,9 @@ public class CraftingRecipes {
.addMaterial('A', EndItems.AMBER_GEM)
.addMaterial('P', Items.ENDER_PEARL)
.build();
GridRecipe.make("iron_chandelier", EndBlocks.IRON_CHANDELIER).setShape("I#I", " # ").addMaterial('#', Items.IRON_INGOT).addMaterial('I', EndItems.LUMECORN_ROD).setGroup("end_metal_chandelier").build();
GridRecipe.make("gold_chandelier", EndBlocks.GOLD_CHANDELIER).setShape("I#I", " # ").addMaterial('#', Items.GOLD_INGOT).addMaterial('I', EndItems.LUMECORN_ROD).setGroup("end_metal_chandelier").build();
}
private static void registerLantern(String name, Block lantern, Block slab) {

View file

@ -20,6 +20,7 @@ import ru.betterend.blocks.BulbVineBlock;
import ru.betterend.blocks.BulbVineLanternBlock;
import ru.betterend.blocks.BulbVineLanternColoredBlock;
import ru.betterend.blocks.BulbVineSeedBlock;
import ru.betterend.blocks.ChandelierBlock;
import ru.betterend.blocks.CharniaBlock;
import ru.betterend.blocks.ChorusGrassBlock;
import ru.betterend.blocks.DenseEmeraldIceBlock;
@ -306,6 +307,11 @@ public class EndBlocks {
public static final Block IRON_BULB_LANTERN = registerBlock("iron_bulb_lantern", new BulbVineLanternBlock());
public static final ColoredMaterial IRON_BULB_LANTERN_COLORED = new ColoredMaterial(BulbVineLanternColoredBlock::new, IRON_BULB_LANTERN, false);
public static final Block GOLD_BULB_LANTERN = registerBlock("gold_bulb_lantern", new BulbVineLanternBlock());
public static final ColoredMaterial GOLD_BULB_LANTERN_COLORED = new ColoredMaterial(BulbVineLanternColoredBlock::new, GOLD_BULB_LANTERN, false);
public static final Block IRON_CHANDELIER = EndBlocks.registerBlock("iron_chandelier", new ChandelierBlock(Blocks.GOLD_BLOCK));
public static final Block GOLD_CHANDELIER = EndBlocks.registerBlock("gold_chandelier", new ChandelierBlock(Blocks.GOLD_BLOCK));
// Blocks With Entity //
public static final Block END_STONE_SMELTER = registerBlock("end_stone_smelter", new EndStoneSmelter());