Anvils fix
This commit is contained in:
parent
193fc41fb7
commit
1342326e70
9 changed files with 62 additions and 97 deletions
|
@ -1,20 +1,14 @@
|
|||
package ru.betterend.blocks;
|
||||
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
||||
import ru.betterend.blocks.basis.EndAnvilBlock;
|
||||
import ru.betterend.item.EndAnvilItem;
|
||||
import ru.betterend.item.material.EndToolMaterial;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.registry.EndItems;
|
||||
|
||||
public class AeterniumAnvil extends EndAnvilBlock {
|
||||
|
||||
protected final Item anvilItem;
|
||||
|
||||
public AeterniumAnvil() {
|
||||
super(EndBlocks.AETERNIUM_BLOCK.defaultMaterialColor(), EndToolMaterial.AETERNIUM.getLevel());
|
||||
this.anvilItem = EndItems.registerEndItem("aeternuim_anvil_item", new EndAnvilItem(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -25,9 +19,4 @@ public class AeterniumAnvil extends EndAnvilBlock {
|
|||
}
|
||||
return durability;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item asItem() {
|
||||
return anvilItem;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraft.world.level.block.state.StateDefinition;
|
|||
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import ru.bclib.blocks.BaseAnvilBlock;
|
||||
import ru.betterend.blocks.complex.MetalMaterial;
|
||||
import ru.betterend.item.EndAnvilItem;
|
||||
|
@ -20,12 +21,14 @@ import java.util.Objects;
|
|||
public class EndAnvilBlock extends BaseAnvilBlock {
|
||||
|
||||
protected final int level;
|
||||
protected final Item anvilItem;
|
||||
protected IntegerProperty durability;
|
||||
protected MetalMaterial metalMaterial;
|
||||
protected int maxDurability;
|
||||
|
||||
public EndAnvilBlock(MaterialColor color, int level) {
|
||||
super(color);
|
||||
this.anvilItem = new EndAnvilItem(this);
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
|
@ -63,16 +66,12 @@ public class EndAnvilBlock extends BaseAnvilBlock {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public Item asItem() {
|
||||
if (metalMaterial != null) {
|
||||
return metalMaterial.anvilItem;
|
||||
}
|
||||
return Item.byBlock(this);
|
||||
return anvilItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext blockPlaceContext) {
|
||||
public BlockState getStateForPlacement(@NotNull BlockPlaceContext blockPlaceContext) {
|
||||
return Objects.requireNonNull(super.getStateForPlacement(blockPlaceContext)).setValue(durability, maxDurability);
|
||||
}
|
||||
|
||||
|
@ -88,8 +87,7 @@ public class EndAnvilBlock extends BaseAnvilBlock {
|
|||
|
||||
public static BlockState applyDamage(BlockState blockState) {
|
||||
Block anvilBlock = blockState.getBlock();
|
||||
if (anvilBlock instanceof EndAnvilBlock) {
|
||||
EndAnvilBlock endAnvilBlock = (EndAnvilBlock) anvilBlock;
|
||||
if (anvilBlock instanceof EndAnvilBlock endAnvilBlock) {
|
||||
IntegerProperty durability = endAnvilBlock.getDurability();
|
||||
int damage = blockState.getValue(durability) - 1;
|
||||
if (damage > 0) {
|
||||
|
|
|
@ -66,7 +66,6 @@ public class MetalMaterial {
|
|||
public final ColoredMaterial bulb_lantern_colored;
|
||||
|
||||
public final Block anvilBlock;
|
||||
public final Item anvilItem;
|
||||
|
||||
public final Item rawOre;
|
||||
public final Item nugget;
|
||||
|
@ -158,8 +157,7 @@ public class MetalMaterial {
|
|||
leggings = EndItems.registerEndItem(name + "_leggings", new EndArmorItem(armor, EquipmentSlot.LEGS, itemSettings));
|
||||
boots = EndItems.registerEndItem(name + "_boots", new EndArmorItem(armor, EquipmentSlot.FEET, itemSettings));
|
||||
|
||||
anvilBlock = EndBlocks.registerBlock(name + "_anvil", new EndAnvilBlock(this, block.defaultMaterialColor(), level));
|
||||
anvilItem = EndItems.registerEndItem(name + "_anvil_item", new EndAnvilItem(anvilBlock));
|
||||
anvilBlock = EndBlocks.registerAnvil(name + "_anvil", new EndAnvilBlock(this, block.defaultMaterialColor(), level));
|
||||
|
||||
if (hasOre) {
|
||||
FurnaceRecipe.make(BetterEnd.MOD_ID, name + "_ingot_furnace_ore", ore, ingot).checkConfig(Configs.RECIPE_CONFIG).setGroup("end_ingot").buildWithBlasting();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue