Bookshelves

This commit is contained in:
paulevsGitch 2020-11-02 01:42:47 +03:00
parent 9ed5b7df19
commit 0a8e73d9d9
15 changed files with 131 additions and 59 deletions

View file

@ -0,0 +1,61 @@
package ru.betterend.blocks.basis;
import java.io.Reader;
import java.util.Collections;
import java.util.List;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import ru.betterend.BetterEnd;
import ru.betterend.interfaces.Patterned;
public class BlockBookshelf extends BlockBase {
public BlockBookshelf(Block source) {
super(FabricBlockSettings.copyOf(source));
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.get(LootContextParameters.TOOL);
if (tool != null && tool.isEffectiveOn(state)) {
int silk = EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool);
if (silk > 0) {
return Collections.singletonList(new ItemStack(this));
}
}
return Collections.singletonList(new ItemStack(Items.BOOK, 3));
}
@Override
public Identifier statePatternId() {
return Patterned.BLOCK_STATES_PATTERN;
}
@Override
public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this);
String name = getName(blockId);
return Patterned.createJson(Patterned.BOOKSHELF, BetterEnd.makeID(name), blockId.getPath());
}
@Override
public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this);
String name = getName(blockId);
return Patterned.createJson(data, BetterEnd.makeID(name), blockId.getPath());
}
private String getName(Identifier blockId) {
String name = blockId.getPath();
return name.replace("_bookshelf", "");
}
}

View file

@ -1,4 +1,4 @@
package ru.betterend.blocks;
package ru.betterend.blocks.basis;
import java.util.List;

View file

@ -12,6 +12,7 @@ import ru.betterend.blocks.basis.BlockBark;
import ru.betterend.blocks.basis.BlockBarkStripable;
import ru.betterend.blocks.basis.BlockBarrel;
import ru.betterend.blocks.basis.BlockBase;
import ru.betterend.blocks.basis.BlockBookshelf;
import ru.betterend.blocks.basis.BlockChest;
import ru.betterend.blocks.basis.BlockCraftingTable;
import ru.betterend.blocks.basis.BlockDoor;
@ -54,6 +55,7 @@ public class WoodenMaterial {
public final Block chest;
public final Block barrel;
public final Block shelf;
public WoodenMaterial(String name, MaterialColor woodColor, MaterialColor planksColor) {
FabricBlockSettings materialPlanks = FabricBlockSettings.copyOf(Blocks.OAK_PLANKS).materialColor(planksColor);
@ -80,6 +82,7 @@ public class WoodenMaterial {
chest = EndBlocks.registerBlock(name + "_chest", new BlockChest(planks));
barrel = EndBlocks.registerBlock(name + "_barrel", new BlockBarrel(planks));
shelf = EndBlocks.registerBlock(name + "_bookshelf", new BlockBookshelf(planks));
// Recipes //
GridRecipe.make(name + "_planks", planks).setOutputCount(4).setList("#").addMaterial('#', log, bark, log_stripped, bark_stripped).setGroup("end_planks").build();

View file

@ -69,6 +69,7 @@ public interface Patterned {
public final static Identifier PEDESTAL_MODEL_TOP = BetterEnd.makeID("patterns/block/pattern_pedestal_top.json");
public final static Identifier PEDESTAL_MODEL_BOTTOM = BetterEnd.makeID("patterns/block/pattern_pedestal_bottom.json");
public final static Identifier PEDESTAL_MODEL_PILLAR = BetterEnd.makeID("patterns/block/pattern_pedestal_pillar.json");
public final static Identifier BOOKSHELF = BetterEnd.makeID("patterns/block/bookshelf.json");
//Models Item
public final static Identifier WALL_ITEM_MODEL = BetterEnd.makeID("patterns/item/pattern_wall.json");

View file

@ -28,7 +28,6 @@ import ru.betterend.blocks.BlockLacugroveSapling;
import ru.betterend.blocks.BlockMossyGlowshroomCap;
import ru.betterend.blocks.BlockMossyGlowshroomHymenophore;
import ru.betterend.blocks.BlockMossyGlowshroomSapling;
import ru.betterend.blocks.BlockOre;
import ru.betterend.blocks.BlockPath;
import ru.betterend.blocks.BlockPythadendronSapling;
import ru.betterend.blocks.BlockShadowGrass;
@ -46,6 +45,7 @@ import ru.betterend.blocks.RunedFlavolite;
import ru.betterend.blocks.TerminiteBlock;
import ru.betterend.blocks.basis.BlockGlowingFur;
import ru.betterend.blocks.basis.BlockLeaves;
import ru.betterend.blocks.basis.BlockOre;
import ru.betterend.blocks.basis.BlockSimpleLeaves;
import ru.betterend.blocks.basis.BlockVine;
import ru.betterend.blocks.complex.StoneMaterial;

View file

@ -0,0 +1,7 @@
{
"parent": "minecraft:block/cube_column",
"textures": {
"end": "betterend:block/%parent%_planks",
"side": "betterend:block/%parent%_bookshelf"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 691 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB