Ore Block drop fix
This commit is contained in:
parent
dc823fb7d1
commit
7ddb41006d
2 changed files with 14 additions and 2 deletions
|
@ -1,6 +1,8 @@
|
||||||
package ru.betterend.blocks.basis;
|
package ru.betterend.blocks.basis;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
|
@ -23,8 +25,9 @@ public class BlockOre extends OreBlock {
|
||||||
private final Item dropItem;
|
private final Item dropItem;
|
||||||
private final int minCount;
|
private final int minCount;
|
||||||
private final int maxCount;
|
private final int maxCount;
|
||||||
|
private final int expirience;
|
||||||
|
|
||||||
public BlockOre(Item drop, int minCount, int maxCount) {
|
public BlockOre(Item drop, int minCount, int maxCount, int expirience) {
|
||||||
super(FabricBlockSettings.of(Material.STONE, MaterialColor.SAND)
|
super(FabricBlockSettings.of(Material.STONE, MaterialColor.SAND)
|
||||||
.hardness(3F)
|
.hardness(3F)
|
||||||
.resistance(9F)
|
.resistance(9F)
|
||||||
|
@ -33,12 +36,21 @@ public class BlockOre extends OreBlock {
|
||||||
this.dropItem = drop;
|
this.dropItem = drop;
|
||||||
this.minCount = minCount;
|
this.minCount = minCount;
|
||||||
this.maxCount = maxCount;
|
this.maxCount = maxCount;
|
||||||
|
this.expirience = expirience;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getExperienceWhenMined(Random random) {
|
||||||
|
return this.expirience > 0 ? random.nextInt(expirience) + 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
||||||
ItemStack tool = builder.get(LootContextParameters.TOOL);
|
ItemStack tool = builder.get(LootContextParameters.TOOL);
|
||||||
if (tool != null && tool.isEffectiveOn(state)) {
|
if (tool != null && tool.isEffectiveOn(state)) {
|
||||||
|
if (EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
||||||
|
return Collections.singletonList(new ItemStack(this));
|
||||||
|
}
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int fortune = EnchantmentHelper.getLevel(Enchantments.FORTUNE, tool);
|
int fortune = EnchantmentHelper.getLevel(Enchantments.FORTUNE, tool);
|
||||||
if (fortune > 0) {
|
if (fortune > 0) {
|
||||||
|
|
|
@ -157,7 +157,7 @@ public class EndBlocks {
|
||||||
public static final Block TWISTED_VINE = registerBlock("twisted_vine", new BlockVine());
|
public static final Block TWISTED_VINE = registerBlock("twisted_vine", new BlockVine());
|
||||||
|
|
||||||
// Ores //
|
// Ores //
|
||||||
public static final Block ENDER_ORE = registerBlock("ender_ore", new BlockOre(EndItems.ENDER_DUST, 1, 3));
|
public static final Block ENDER_ORE = registerBlock("ender_ore", new BlockOre(EndItems.ENDER_DUST, 1, 3, 5));
|
||||||
|
|
||||||
// Materials //
|
// Materials //
|
||||||
public static final Block TERMINITE_BLOCK = registerBlock("terminite_block", new TerminiteBlock());
|
public static final Block TERMINITE_BLOCK = registerBlock("terminite_block", new TerminiteBlock());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue