Added Ender Ore and Ender Dust
This commit is contained in:
parent
16c5a9131b
commit
1966d89dc7
13 changed files with 94 additions and 7 deletions
BIN
psd/ender_dust.psd
Normal file
BIN
psd/ender_dust.psd
Normal file
Binary file not shown.
BIN
psd/ender_ore.psd
Normal file
BIN
psd/ender_ore.psd
Normal file
Binary file not shown.
54
src/main/java/ru/betterend/blocks/BlockOre.java
Normal file
54
src/main/java/ru/betterend/blocks/BlockOre.java
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
|
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.Material;
|
||||||
|
import net.minecraft.block.MaterialColor;
|
||||||
|
import net.minecraft.block.OreBlock;
|
||||||
|
import net.minecraft.enchantment.EnchantmentHelper;
|
||||||
|
import net.minecraft.enchantment.Enchantments;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
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.util.math.MathHelper;
|
||||||
|
|
||||||
|
import ru.betterend.util.MHelper;
|
||||||
|
|
||||||
|
public class BlockOre extends OreBlock {
|
||||||
|
private final Item dropItem;
|
||||||
|
private final int minCount;
|
||||||
|
private final int maxCount;
|
||||||
|
|
||||||
|
public BlockOre(Item drop, int minCount, int maxCount) {
|
||||||
|
super(FabricBlockSettings.of(Material.STONE, MaterialColor.SAND)
|
||||||
|
.hardness(3F)
|
||||||
|
.resistance(9F)
|
||||||
|
.requiresTool()
|
||||||
|
.sounds(BlockSoundGroup.STONE));
|
||||||
|
this.dropItem = drop;
|
||||||
|
this.minCount = minCount;
|
||||||
|
this.maxCount = maxCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
||||||
|
ItemStack tool = builder.get(LootContextParameters.TOOL);
|
||||||
|
if (tool.isEffectiveOn(state))
|
||||||
|
{
|
||||||
|
int fortune = EnchantmentHelper.getLevel(Enchantments.FORTUNE, tool);
|
||||||
|
int min = MathHelper.clamp(minCount + fortune, 0, maxCount);
|
||||||
|
if (min == maxCount)
|
||||||
|
return Lists.newArrayList(new ItemStack(dropItem, maxCount));
|
||||||
|
int count = MHelper.randRange(min, maxCount, MHelper.RANDOM);
|
||||||
|
return Lists.newArrayList(new ItemStack(dropItem, count));
|
||||||
|
}
|
||||||
|
return Lists.newArrayList();
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,24 +7,24 @@ import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
import ru.betterend.BetterEnd;
|
import ru.betterend.BetterEnd;
|
||||||
import ru.betterend.blocks.BlockEndstoneDust;
|
import ru.betterend.blocks.BlockEndstoneDust;
|
||||||
|
import ru.betterend.blocks.BlockOre;
|
||||||
import ru.betterend.blocks.BlockWetMycelium;
|
import ru.betterend.blocks.BlockWetMycelium;
|
||||||
import ru.betterend.tab.CreativeTab;
|
import ru.betterend.tab.CreativeTab;
|
||||||
|
|
||||||
public class BlockRegistry {
|
public class BlockRegistry {
|
||||||
public static final Block ENDSTONE_DUST = registerBlock("endstone_dust", new BlockEndstoneDust());
|
public static final Block ENDSTONE_DUST = registerBlock("endstone_dust", new BlockEndstoneDust());
|
||||||
public static final Block WET_MYCELIUM = registerBlock("wet_mycelium", new BlockWetMycelium());
|
public static final Block WET_MYCELIUM = registerBlock("wet_mycelium", new BlockWetMycelium());
|
||||||
|
public static final Block ENDER_ORE = registerBlock("ender_ore", new BlockOre(ItemRegistry.ENDER_DUST, 1, 3));
|
||||||
|
|
||||||
public static void register() {}
|
public static void register() {}
|
||||||
|
|
||||||
private static Block registerBlock(String name, Block block)
|
private static Block registerBlock(String name, Block block) {
|
||||||
{
|
|
||||||
Registry.register(Registry.BLOCK, new Identifier(BetterEnd.MOD_ID, name), block);
|
Registry.register(Registry.BLOCK, new Identifier(BetterEnd.MOD_ID, name), block);
|
||||||
ItemRegistry.registerItem(name, new BlockItem(block, new Item.Settings().group(CreativeTab.END_TAB)));
|
ItemRegistry.registerItem(name, new BlockItem(block, new Item.Settings().group(CreativeTab.END_TAB)));
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Block registerBlockNI(String name, Block block)
|
public static Block registerBlockNI(String name, Block block) {
|
||||||
{
|
|
||||||
return Registry.register(Registry.BLOCK, new Identifier(BetterEnd.MOD_ID, name), block);
|
return Registry.register(Registry.BLOCK, new Identifier(BetterEnd.MOD_ID, name), block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import net.minecraft.item.BlockItem;
|
import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemGroup;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
|
@ -14,9 +15,11 @@ import ru.betterend.BetterEnd;
|
||||||
public class ItemRegistry {
|
public class ItemRegistry {
|
||||||
private static final List<Item> MOD_BLOCKS = Lists.newArrayList();
|
private static final List<Item> MOD_BLOCKS = Lists.newArrayList();
|
||||||
private static final List<Item> MOD_ITEMS = Lists.newArrayList();
|
private static final List<Item> MOD_ITEMS = Lists.newArrayList();
|
||||||
|
|
||||||
|
public final static Item ENDER_DUST = registerItem("ender_dust", new Item((new Item.Settings()).group(ItemGroup.MATERIALS)));
|
||||||
|
|
||||||
protected static Item registerItem(String name, Item item) {
|
protected static Item registerItem(String name, Item item) {
|
||||||
if (item instanceof BlockItem && item != Items.AIR) {
|
if (item != Items.AIR) {
|
||||||
Registry.register(Registry.ITEM, new Identifier(BetterEnd.MOD_ID, name), item);
|
Registry.register(Registry.ITEM, new Identifier(BetterEnd.MOD_ID, name), item);
|
||||||
if (item instanceof BlockItem)
|
if (item instanceof BlockItem)
|
||||||
MOD_BLOCKS.add(item);
|
MOD_BLOCKS.add(item);
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"variants": {
|
||||||
|
"": {
|
||||||
|
"model": "betterend:block/ender_ore"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,9 @@
|
||||||
{
|
{
|
||||||
"itemGroup.betterend.items": "Better End",
|
"itemGroup.betterend.items": "Better End",
|
||||||
|
|
||||||
"block.betterend.wet_mycelium": "Wet Mycelium",
|
"block.betterend.wet_mycelium": "Wet Mycelium",
|
||||||
"block.betterend.endstone_dust": "End Stone Dust"
|
"block.betterend.endstone_dust": "End Stone Dust",
|
||||||
|
"block.betterend.ender_ore": "Ender Ore",
|
||||||
|
|
||||||
|
"item.betterend.ender_dust": "Ender Dust"
|
||||||
}
|
}
|
|
@ -1,5 +1,9 @@
|
||||||
{
|
{
|
||||||
"itemGroup.betterend.items": "Улучшенный Край",
|
"itemGroup.betterend.items": "Улучшенный Край",
|
||||||
|
|
||||||
"block.betterend.wet_mycelium": "Влажный мицелий",
|
"block.betterend.wet_mycelium": "Влажный мицелий",
|
||||||
"block.betterend.endstone_dust": "Эндерняковая пыль"
|
"block.betterend.endstone_dust": "Эндерняковая пыль",
|
||||||
|
"block.betterend.ender_ore": "Руда Эндера",
|
||||||
|
|
||||||
|
"item.betterend.ender_dust": "Пыль Эндера"
|
||||||
}
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "block/cube_all",
|
||||||
|
"textures": {
|
||||||
|
"all": "betterend:block/ender_ore"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "betterend:item/ender_dust"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"parent": "betterend:block/ender_ore"
|
||||||
|
}
|
BIN
src/main/resources/assets/betterend/textures/block/ender_ore.png
Normal file
BIN
src/main/resources/assets/betterend/textures/block/ender_ore.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 848 B |
BIN
src/main/resources/assets/betterend/textures/item/ender_dust.png
Normal file
BIN
src/main/resources/assets/betterend/textures/item/ender_dust.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 349 B |
Loading…
Add table
Add a link
Reference in a new issue