package net.minecraft.world.level.block; import net.minecraft.world.item.ItemStack; import javax.annotation.Nullable; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.core.BlockPos; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BannerBlockEntity; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.item.DyeColor; public abstract class AbstractBannerBlock extends BaseEntityBlock { private final DyeColor color; protected AbstractBannerBlock(final DyeColor bdg, final Properties c) { super(c); this.color = bdg; } @Override public boolean isPossibleToRespawnInThis() { return true; } @Override public BlockEntity newBlockEntity(final BlockGetter bjd) { return new BannerBlockEntity(this.color); } @Override public void setPlacedBy(final Level bjt, final BlockPos fk, final BlockState byg, @Nullable final LivingEntity akw, final ItemStack bek) { if (bek.hasCustomHoverName()) { final BlockEntity bwi7 = bjt.getBlockEntity(fk); if (bwi7 instanceof BannerBlockEntity) { ((BannerBlockEntity)bwi7).setCustomName(bek.getHoverName()); } } } @Override public ItemStack getCloneItemStack(final BlockGetter bjd, final BlockPos fk, final BlockState byg) { final BlockEntity bwi5 = bjd.getBlockEntity(fk); if (bwi5 instanceof BannerBlockEntity) { return ((BannerBlockEntity)bwi5).getItem(byg); } return super.getCloneItemStack(bjd, fk, byg); } public DyeColor getColor() { return this.color; } }