39 lines
1.3 KiB
Java
39 lines
1.3 KiB
Java
package com.learning.block;
|
|
|
|
import com.learning.util.ModTags.ItemTags;
|
|
import java.util.List;
|
|
|
|
import net.minecraft.block.AbstractBlock;
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.block.BlockState;
|
|
import net.minecraft.util.math.BlockPos;
|
|
import net.minecraft.world.World;
|
|
import net.minecraft.entity.Entity;
|
|
import net.minecraft.entity.ItemEntity;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.item.Items;
|
|
import net.minecraft.item.Item.TooltipContext;
|
|
import net.minecraft.item.tooltip.TooltipType;
|
|
import net.minecraft.text.Text;
|
|
|
|
public class TransformBlock extends Block {
|
|
public TransformBlock(AbstractBlock.Settings settings) {
|
|
super(settings);
|
|
}
|
|
|
|
@Override
|
|
public void onSteppedOn(World world, BlockPos pos, BlockState state, Entity entity) {
|
|
if (!world.isClient() && entity instanceof ItemEntity itemEntity) {
|
|
if (itemEntity.getStack().isIn(ItemTags.DIAMOND_TRANSFORMABLE)) {
|
|
itemEntity.setStack(new ItemStack(Items.DIAMOND, itemEntity.getStack().getCount()));
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void appendTooltip(ItemStack stack, TooltipContext context, List<Text> tooltip, TooltipType type) {
|
|
super.appendTooltip(stack, context, tooltip, type);
|
|
tooltip.add(Text.translatable("toolTip.learning.transform_block"));
|
|
}
|
|
}
|