use of net.minecraft.block.BlockBanner in project BetterWithAddons by DaedalusGame.
the class TileEntityBannerDetector method checkBanner.
private boolean checkBanner(BlockPos pos, ItemStack filter, Class type) {
IBlockState state = world.getBlockState(pos);
if (type.isInstance(state.getBlock())) {
BlockBanner bannerblock = (BlockBanner) state.getBlock();
ItemStack banner = bannerblock.getItem(world, pos, state);
return BannerUtil.isSameBanner(filter, banner);
}
return false;
}
use of net.minecraft.block.BlockBanner in project BetterWithAddons by DaedalusGame.
the class AssortedHandler method onBlockInteract.
@SubscribeEvent
public void onBlockInteract(PlayerInteractEvent event) {
World world = event.getWorld();
BlockPos pos = event.getPos();
IBlockState blockstate = world.getBlockState(pos);
EntityPlayer player = event.getEntityPlayer();
if (blockstate.getBlock() instanceof BlockBanner) {
EnumHand hand = EnumHand.MAIN_HAND;
ItemStack stack = player.getHeldItemMainhand();
BlockBanner bannerblock = (BlockBanner) blockstate.getBlock();
if (stack.isEmpty() && player.isSneaking() && player.getItemStackFromSlot(EntityEquipmentSlot.HEAD).isEmpty()) {
ItemStack bannerstack = bannerblock.getItem(world, pos, blockstate);
player.swingArm(hand);
world.removeTileEntity(pos);
world.setBlockToAir(pos);
player.setItemStackToSlot(EntityEquipmentSlot.HEAD, bannerstack);
if (!event.getWorld().isRemote) {
event.setCanceled(true);
}
}
}
}
Aggregations